Link to home
Start Free TrialLog in
Avatar of Gerhardpet
GerhardpetFlag for Canada

asked on

Crystal report formula

I have a report where I'm trying to use a formula to look in the details section for a variable and pass that to the header as a declaration numbervar.

Then in the footer I want to print a message based on what the declaration is in the header

I'm attaching the report here.

Vendor Flag Checker (in the detail section)
Vendor Flag Starter (header)
Vendor Flag Display (message in footer)
test formula (test formula to test Vendor Flag Starter)

I can't get it to work for the Vendor Flag Checker (header) to declare the value to test formula (footer)

Anyone who can help me?
EIS-Order-Confirmation-EE.zip
Avatar of Mike McCracken
Mike McCracken

You can upload rpt files directly

You need to add WhilePrintingRecords to the formulas.

Vendor Flag Starter
WhilePrintingRecords;
global numbervar perferedflag;
perferedflag := 2;

Open in new window


Vendor Flag Checker
WhilePrintingRecords;
global numbervar perferedflag;

if {INVENTORY.PREFERRED_VENDOR} = "9MMAG" then 
    perferedflag := 1

Open in new window


Vendor Flag Display
WhilePrintingRecords;
global numbervar perferedflag;

if  perferedflag = 1 then 
     "Please note: unless otherwise stated below the order line, that the planning, controlling and execution of all the processes at maxon motor are in accordance with the ISO9001 standards"

Open in new window



mlmcc
EIS-Order-Confirmation-EE.rpt
Avatar of Gerhardpet

ASKER

Still not working.

Did the formulas as per your suggestions and it does not print the message.

Also testing with this formula I get 0 as a value

whilereadingrecords;
numbervar perferedlflag;
perferedlflag 

Open in new window


Appreciate your help Michael!
You need to name all the variables the same.

YOu have both perferedlflag  and perferedflag
 
mlmcc
Yes notice that in the test formula I had the spelling wrong. Now I have double checked and all spellings are correct but still no luck.

Not working. As far as I know the test formula should return a value of 2 and it is 0
Did you try the report I uploaded?

mlmcc
Yes just now and get the error below. Before I was just testing your formulas in the original report

Also my reports have to be in Crystal 10. If they have been updated in a newer version they won't work.

User generated image
My report was saved in CR XI.  It shouldn't matter but it is possible.

Upload your latest version.

mlmcc
Here is the latest version

This is for an old Sage ERP using run time crystal 10 and if reports are edited with a newer version I get errors
EIS-Order-Confirmation---Plain-P.rpt
Don't suppress the formulas.  They tend not to execute.
If you don't want to display anything use this trick

WhilePrintingRecords;
global numbervar perferedflag;

if {INVENTORY.PREFERRED_VENDOR} = "9MMAG" then 
    perferedflag := 1;

""

Open in new window


THe formula now calculates what you want but it displays a null/empty string.

Change your test formula to use the WhilePrintingRecord.  If you evaluate it in the Reading Records pass the other formulas haven't been evaluated yet.

mlmcc
The formulas are working now. But still one small problem remaining. I want to print the display formula in the Page Footer. It prints on the Page Footer on the first page but not the second page.

I have a Page Footer where it prints other content. It prints on all pages but my display formula will only print on the first page. The display formula is in the same Page Footer.

Any ideas why?
No idea

mlmcc
You are talking about the {@Vendor Flag Display} formula, correct?

 You set the variable in the detail section, so the result that you get from that formula in the page footer will depend on the values in INVENTORY.PREFERRED_VENDOR in the detail records on each page.  If that's not what you're seeing, I don't know why.

 FWIW, I did notice that {@test furmula} (which is also in the page footer) is using WhileReadingRecords, while the other formulas that use that variable are using WhilePrintingRecords, so the results that you get from {@test furmula} may not match what's in the other formulas.

 James
Actually, now that I look at it again, since you only set the variable if PREFERRED_VENDOR has a specific value, the result that you get from {@Vendor Flag Display} in the page footer will depend on what was in PREFERRED_VENDOR in all of the records up to that point, not just the records on each page.

 James
James,
I think you are correct. When I use this test formula it declare a 1 on the first page and zero on the second page.

WhilePrintingRecords;
global numbervar perferedflag;
perferedflag

Open in new window


On the order I only need to have 1 SKU where PREFERRED_VENDOR = "VENDOR" and all other SKU's could be "VENDORXX". When the variable finds one record = "VENDOR" then it should display the messages on all pages.

Does that make sense? Do you have any idea how I could make this work?
ASKER CERTIFIED SOLUTION
Avatar of James0628
James0628

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
There can be multiple vendors on the report and I only want PREFERRED_VENDOR = "9MMAG"

Will the Sum formula work then?
I can't believe how much time I spent on the report.

James, your idea works just like I wanted and was easy to do. Thanks for your help.
You're welcome.  Glad I could help.

 James