?
Solved

crystal reports page header value updating on record change

Posted on 2011-03-01
4
Medium Priority
?
756 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 101

Accepted Solution

by:
mlmcc earned 2000 total points
ID: 35013186
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 35

Expert Comment

by:James0628
ID: 35015549
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
ID: 35016738
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
ID: 35016754
It worked exactly as desired.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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. …
Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

771 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