Solved

crystal reports page header value updating on record change

Posted on 2011-03-01
4
702 Views
Last Modified: 2012-08-13
I have a formula where I capture the last 3 characters of a field (f_taskid).  The formula is placed in the page header to capture the value for the first task on that page.  Then later in the page footer I have another formula that references the value from the page header and concatenates it to the current value of the task id.  The issue is that both values are always the same.

//f_taskid - in page header
right({task.taskid},3)

//f_taskrange - in page footer
{@f_taskid} + " - " right({task.taskid},3)

when I run the report with the header unsuppressed I can see the first task as "001".
let's say there are 14 tasks on the page - when I look at the f_taskrange it is "014 - 014" instead of "001 - 014".

Since the initial value is only in the header it doesn't make sense to me that it is updating on every record change.  I tried using a global variable, but found that it either never updated (remained the same on every page) or it acted exactly the same as what I have above.  I'm sure I am missing something simple here, but for the life of me I can't see it.
0
Comment
Question by:smdrzal
  • 2
4 Comments
 
LVL 100

Accepted Solution

by:
mlmcc earned 500 total points
Comment Utility
When you reference the formula you actually reevaluate it with th ecurrent record.

Try this idea

Page Header formula
//f_taskid - in page header
WhilePrintingRecords;
Global StringVar strFirstTask;
strFirstTask := right({task.taskid},3);
strFirstTask

FOoter formula
WhilePrintingRecords;
Global StringVar strFirstTask;
strFirstTask  &  " - " & right({task.taskid},3)

mlmcc


0
 
LVL 34

Expert Comment

by:James0628
Comment Utility
mlmcc has already given you a solution that will probably work, but just to add some explanation.

 Global variables can be picky.  Adding WhilePrintingRecords to each formula that uses a global variable (as in mlmcc's formulas) may help.  You may also need to put a formula that declares that variable in the report header (not page header), to declare the variable at the very beginning of the report.

 Another option would be to use a shared variable instead of global.  CR handles shared variables a bit differently and, personally, I find them a bit easier to use.

 James
0
 

Author Comment

by:smdrzal
Comment Utility
The solution mlmcc provided does exactly what I was expecting.  

It seems so odd as that solution is what I thought I had done - in complete frustration I've since deleted and started over so can't go back and check my syntax.  The only major difference was that I had initialized it in the report header as James0628 suggested.  

Anyway all is good now - thanks for the help.  I did make a minor alteration so it only updates on even numbered pages - which works as desired.

WhilePrintingRecords;
Global StringVar strFirstTask;
If pagenumber mod 2 = 0
Then
    strFirstTask := right({task.taskid},3);
strFirstTask
0
 

Author Closing Comment

by:smdrzal
Comment Utility
It worked exactly as desired.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now