Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: formula field is zero in the first group record Post Reply Post New Topic
Author Message
Macavity
Groupie
Groupie


Joined: 24 Sep 2012
Online Status: Offline
Posts: 93
Quote Macavity Replybullet Topic: formula field is zero in the first group record
     Posted: 14 Feb 2013 at 11:00am
Hello,
 
I have a formula field on a group header which does a datediff.
Both dates are on the report and the datediff is fine for all records, exept for the first record, the field is zero instead of 25.
 
have tried whileprintingrecords; and onfirstrecord; in the formula, but it doesn't solve the problem.
 
Any ideas ?
 
thanks
 
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 14 Feb 2013 at 11:17am
what is the formula?
IP IP Logged
Macavity
Groupie
Groupie


Joined: 24 Sep 2012
Online Status: Offline
Posts: 93
Quote Macavity Replybullet Posted: 15 Feb 2013 at 3:52am
onfirstrecord;
whileprintingrecords;
 
local datetimevar d1:= {startdate}
local datetimevar d2:= {enddate}
 
datediff("D", d2, d1)
 
result :
startdate               enddate           diff
2012-12-08          2013-01-02     0
2012-12-08          2013-01-02     25
2012-12-09          2013-01-02     24 
2012-12-23          2013-01-08     16
 
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 15 Feb 2013 at 7:12am
the on firstrecord is not needed. it only references the first record in the report, not the group.
You should just be able to use the below and place in the group header to display the rsult of the first row.
 
datediff("d", {startdate}, {enddate})
IP IP Logged
Macavity
Groupie
Groupie


Joined: 24 Sep 2012
Online Status: Offline
Posts: 93
Quote Macavity Replybullet Posted: 07 Mar 2013 at 11:49am
I finally found the real problem.
The start date is a variable passed on from a subreport.
 
The subreport was in the same section as the rest of the fields.
 
I inserted a section on the GH. Copied all the fields into GHb and left the subreport on GHa.
 
problem solved !
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum