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
Solved

crystal reports page header value updating on record change

Posted on 2011-03-01
4
735 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
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 34

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

Suggested Solutions

Title # Comments Views Activity
Crystal Reports  Formula to Command 4 88
Getting a signature to show in Crystal Reports 2 70
Crystal Reports Subreport details 16 66
Crystal Reports get subgroup count 1 56
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 shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

861 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