Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Formulas in Repeated Group Header Post Reply Post New Topic
Author Message
bryanlw123
Newbie
Newbie


Joined: 01 Apr 2011
Online Status: Offline
Posts: 14
Quote bryanlw123 Replybullet Topic: Formulas in Repeated Group Header
     Posted: 11 Apr 2011 at 5:36am
I have a formula in the upper group header that works for the first page but displays zeros for the 2nd and subsequent pages. The formula uses one of the fields returned from the SQL query to calculate an elapsed time. I have the Group Option "Repeat Group Header On Each Page" turned on and "Keep Group Together" turned off. I have two groups nested under the first group. On the Common Tab I have a different Command field being used to provide sorting and grouping order.

How can I get the formula to return the same value for each page.
Thanks for your help!
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 12 Apr 2011 at 3:26am
what is the formula?
IP IP Logged
bryanlw123
Newbie
Newbie


Joined: 01 Apr 2011
Online Status: Offline
Posts: 14
Quote bryanlw123 Replybullet Posted: 12 Apr 2011 at 5:32am
Local NumberVar elapsedTime := 0;
Local StringVar elapsedTimeStr := "";
Local NumberVar et_Trunc := 0;
Local NumberVar et_whole := 0;

elapsedTime := {Command.StartTime}/10000000;

et_whole := elapsedTime / 3600;
et_Trunc := Truncate (et_whole);

if et_Trunc = 0 then
    elapsedTimeStr := elapsedTimeStr + '00:'
else if et_Trunc > 0 and et_Trunc < 9 then
    elapsedTimeStr := elapsedTimeStr + '0' + ToText((et_Trunc), 0) + ':'
else
    elapsedTimeStr := elapsedTimeStr + ToText((et_Trunc), 0) + ':';

et_whole := ((et_whole) - Truncate (et_whole)) * 60;
et_Trunc := Truncate (et_whole);

if et_Trunc = 0 then
    elapsedTimeStr := elapsedTimeStr + '00:'
else if et_Trunc > 0 and et_Trunc < 10 then
    elapsedTimeStr := elapsedTimeStr + '0' + ToText(et_Trunc, 0) + ':'
else
    elapsedTimeStr := elapsedTimeStr + ToText(et_Trunc, 0) + ':';

et_whole := ((et_whole) - Truncate (et_whole)) * 60;

if et_whole = 0 then
    elapsedTimeStr := elapsedTimeStr + '00'
else if et_whole > 0 and et_whole < 10 then
    elapsedTimeStr := elapsedTimeStr + '0' + ToText(et_Whole, 1)
else
    elapsedTimeStr := elapsedTimeStr + ToText(et_Whole, 1);
Thanks for your help!
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 12 Apr 2011 at 5:55am

when you place this sort of formula in a header it will only show records that have been read up to the point of location of the formula (e.g the first row of the group or in a repeated group header rows up to that point in the group)

only formulas that can be created via an insert summary function (or replicated as such) can be used to show values in a header.
IP IP Logged
bryanlw123
Newbie
Newbie


Joined: 01 Apr 2011
Online Status: Offline
Posts: 14
Quote bryanlw123 Replybullet Posted: 12 Apr 2011 at 9:01am
Thanks,

The insert summary function doesn't help, so I suppress the formula when its equal to "00:00:00", which occurs when the Command.StartTime = 0. The user will get the elapsed time on the first page.

I toyed with the idea of a global string array but couldn't figure out how to index it properly and I need to press on with the problem reported in my 3rd posting (Repeated Events Not in Report).

Edited by bryanlw123 - 12 Apr 2011 at 9:02am
Thanks for your help!
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