Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1029
  • Last Modified:

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
0
Gerhardpet
Asked:
Gerhardpet
  • 8
  • 6
  • 4
1 Solution
 
mlmccCommented:
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
0
 
GerhardpetAuthor Commented:
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!
0
 
mlmccCommented:
You need to name all the variables the same.

YOu have both perferedlflag  and perferedflag
 
mlmcc
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
GerhardpetAuthor Commented:
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
0
 
mlmccCommented:
Did you try the report I uploaded?

mlmcc
0
 
GerhardpetAuthor Commented:
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.

error 732
0
 
mlmccCommented:
My report was saved in CR XI.  It shouldn't matter but it is possible.

Upload your latest version.

mlmcc
0
 
GerhardpetAuthor Commented:
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
0
 
mlmccCommented:
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
0
 
GerhardpetAuthor Commented:
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?
0
 
mlmccCommented:
No idea

mlmcc
0
 
James0628Commented:
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
0
 
James0628Commented:
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
0
 
GerhardpetAuthor Commented:
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?
0
 
James0628Commented:
In your report, you have PREFERRED_VENDOR = "9MMAG", not PREFERRED_VENDOR = "VENDOR".

 Ignoring that for the moment, can the records for a single vendor take more than 1 page?  And you may have only 1 record where PREFERRED_VENDOR has the target value, which could be on any of those pages?

 If so, one way to handle that would be to create a formula like this:

if {INVENTORY.PREFERRED_VENDOR} = "9MMAG" then
    1
else
    0


 Then your display formula would be something like:

if Sum ({@formula created above}) > 0 then
     "Please note: unless otherwise stated below <rest of your message>"


 That assumes that there is only one vendor on the report, so you're taking the summary of the first formula for the entire report.  If there could be multiple vendors on a report and you want a separate flag for each vendor, you'd need to group the report by the vendor and change the Sum to be for the group, instead of the entire report.  In that case, you'd also have to have each vendor start on a new page.

 James
0
 
GerhardpetAuthor Commented:
There can be multiple vendors on the report and I only want PREFERRED_VENDOR = "9MMAG"

Will the Sum formula work then?
0
 
GerhardpetAuthor Commented:
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.
0
 
James0628Commented:
You're welcome.  Glad I could help.

 James
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.

  • 8
  • 6
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now