Solved

crystal reports page header value updating on record change

Posted on 2011-03-01
4
746 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 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 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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
Speed Up Crystal Report 5 73
Crystal Reports Format Field with Dashes 6 70
Crystal Reports - group header 2 66
Mask on Parameter CR2008 28 82
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. …
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

734 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