Solved

set variables in Crystal Reports XI

Posted on 2012-04-13
6
307 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
Comment Utility
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
Comment Utility
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
Comment Utility
Can you upload the report?

mlmcc
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 34

Accepted Solution

by:
James0628 earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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. …
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now