Solved

crystal reports page header value updating on record change

Posted on 2011-03-01
4
754 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 500 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

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…
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…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

695 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