Solved

set variables in Crystal Reports XI

Posted on 2012-04-13
6
310 Views
Last Modified: 2012-06-21
I have a report with several groups:
---> Order Type
----------> Ship Date
---------------->Order Number
---------------------> Model Number
----------------------------Detail Row

i want to use the "Supress if repeated" option on the OrderQty at the detail level, but it also supresses the OrderQty of the previous or next order if the OrderQty is the same.  I only need to supress it if the OrderNumber and Model number repeat.

i have created Global vars in a formula and placed in the Report Header:
global stringvar ProjNum;
global stringvar ModelNum;

Then in the Model Number footer:
Global stringvar ModelNum;
evaluateafter ({@detOrderQty});
ModelNum={order_details.ProductName}

In the Order Number footer:
global stringvar ProjNum;
evaluateafter ({@detModelNum});
ProjNum={Orders.ProjectNumber}

and finally in the Detail Line:
Global stringvar ProjNum;
global stringvar ModelNum;
whilereadingrecords;
if ProjNum={Orders.ProjectNumber}
    and ModelNum={order_details.ProductName} then
0
else
{order_details.Quantity}

My assumption was that the group footers would set the global vars and if the current record didn't match the ProjNum and the ModelNum, they would return the OrderQty, else return 0.

Help is appreciated,
Harold
0
Comment
Question by:lanier3532
  • 2
  • 2
  • 2
6 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 37843326
Add WhilePrintingRecords to each formula as the first line

Crystal evaluates formulas when it "can" so in this case they are being evaluated in an early pass through the report and values for variables don't get saved.

mlmcc
0
 

Author Comment

by:lanier3532
ID: 37843436
i put the "WhilePrintingRecords;" as the 1st line of each formula.
no success.
When i have an order with the same Model#, but different ShipTo locations, it still repeats the OrderQty even though the ProjectNumber (OrderNumber) and the ModelNumber are the same.
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 37843534
Can you upload the report?

mlmcc
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 34

Accepted Solution

by:
James0628 earned 500 total points
ID: 37845747
I'm not sure why those formulas aren't working, but I have a few questions/observations:

 In your group footer formulas, you include evaluateafter ({@detOrderQty}) and evaluateafter ({@detModelNum}).  Why?  What's in those formulas?

 You had WhileReadingRecords in the detail formula.  I assume that you removed that when you added WhilePrintingRecords.  You should get an error if you have both.

 You said that you tried to use "Supress if repeated".  I assume that you meant the "Suppress If Duplicated" option in the field format.  Just wanted to make sure that you weren't talking about something else.


 It seems like you could do this using Previous.  Try this as the "Suppress If Duplicated" formula:

not OnFirstRecord and
{Orders.ProjectNumber} = Previous ({Orders.ProjectNumber}) and
{order_details.ProductName} = Previous ({order_details.ProductName}) and
{order_details.Quantity} = Previous ({order_details.Quantity})


 James
0
 

Author Closing Comment

by:lanier3532
ID: 37846129
Yes, i wanted to use the "Suppress if Duplicated" option.  The formulas were a terrible way to do what you elegantly accomplished using the "Previous" reference.  I removed the formulas and used the "Previous" code and all is well.

Thanks again,
Harold
0
 
LVL 34

Expert Comment

by:James0628
ID: 37846396
You're welcome.  Glad I could help.

 FWIW, I'm not sure why your formulas didn't work.  It seemed like they should.  It did occur to me that the EvaluateAfter functions might be a problem.  Specifically, one of your formulas used evaluateafter ({@detOrderQty}).  If {@detOrderQty} was your last formula (that was checking the variables and producing {order_details.Quantity} or 0), maybe that EvaluateAfter was forcing {@detOrderQty} to be evaluated at the wrong time.

 James
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

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…
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 …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

856 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