Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OnFirstRecord Grouping

Status
Not open for further replies.

gdkz

Programmer
Nov 21, 2002
44
0
0
US
(Crystal 8.5)On the first and last record of a group, I want to set a variable equal to a value within that record. I need to do this for every grouping.
So I initialize the variable in the report header
Code:
whileprintingrecords ;
shared datetimevar start_date:= cdatetime("01/01/2006 10:10:00 AM");
shared datetimevar end_date:= cdatetime("01/01/2006 10:10:00 AM");
Then I set the value in the detail section
Code:
Whileprintingrecords;
if OnFirstRecord then 
    datetimevar start_date:= ({PrepLog_ttx.Date/Time})  else
if OnLastRecord then 
   datetimevar end_date:= ({PrepLog_ttx.Date/Time}) ;
Then I have two subreports in the group footer that use this minimum and maximum dates for parameters. Currently it sets the value for the first record and the very last record of all groups. How can I set a variable on the first and last record of every group?

Thanks,
Greg
 
The first sentence described your answer "On the first and last record of a group, I want to set a variable equal to a value within that record"

Except you only need to set the variables once.

Right click the group footer and select insert section below 2 times.

Place each subreport in each new section (B and C).

Group Footer formula:

whileprintingrecords;
shared datevar MinDate:=minimum({table.date},{table.groupfield});
shared datevar MaxDate:=maximum({table.date},{table.groupfield});

Now you can reference them in the subreports if need be using a formula:

whileprintingrecords;
shared datevar MinDate;
shared datevar MaxDate;
"Here's the minimum " & MinDate & " and here's the maximum " & MaxDate

-k
 
Thanks, I see what you are saying. However, no matter what I seem to do, it is generating 'the summary / running total field could not be created." error. I am using ttx files to read xml data from the print engine. The field is a date/time field and I have experimented with datevar and datetimevar to no avail. Any suggestions of where to look?

Thanks,
Greg
 
Thanks, resolved the issue. Works great, just like you suggested!

Thanks,
Greg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top