Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variable set in Page Header not working in Detail 1

Status
Not open for further replies.

jotek

MIS
Oct 9, 2001
21
US
I have set a global variable in a formula, I have placed in the Page Header (I assume thats the place to put it, I tried the Report Header too). It is assigned as follows:

Global NumberVar Max_Period;

Max_Period := maximum(Period); // Period is a field from the returned data set. I want the max period from the record set returned. So I can use it later.

In the detail section I have placed another formula called Col1_Value this code is as follows

Global NumberVar Max_Period;

If Max_period = Period then
Amount_Value // this is a field from the data database
else
Amount_Value_2 // again from the database.

I have other Col#_Value in the detail section that need to do different tests on the Max_Period. The problem is Max_period is always 0 in the detail section.
I don't understand why its not the value I see if I display it in the Page Header. What Am I missing?

Thanks
Joe
I am using CR 8.5

 
Try this instead of using a variable:
1. Place the {Table.Period} field on the detail line. Suppress it if you don't want it to be visible.
2. Right-click on this field abnd select "Summary". Choose "Maximum" as summary type. Choose if you want a summary of all records or of a group (if you are grouping) and place the summary field in the corresponding report or group footer. Suppress it if you don't want it to be visible.
3. Edit your Col1_Value formula. You will find the Maximum Summary in the list of Report Fields in the Formula Editor. Use that instead of your global variable.
 
Rogar's suggestion is a good one and I'd recommend that solution.

But to explain what has gone wrong with your original approach.

Global variables are calculated by default "WhileReadingRecords". If you had made all your formulas "WhilePrintingRecords" they would work as planned. Editor and Publisher of Crystal Clear
 
Thanks for the help. Both solutions work, except I have one addtional problem.

When the Col#_Value is summed in the Groupings, Crystal disables the Summary field so I end up with blank summaries in my groupings. The detail works great but if Crystal detects any traces of a 'maximum' used in the Col#_Value used in the detail it disables the summary function for that column. If you have any other ideas I would appreciate it. One thought is to create my own running totals. But I don't want to do down that route since I have 16 groupings and 12 columns so it seems like a lot of totaling formulas to deal with.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top