?
Solved

set variables in Crystal Reports XI

Posted on 2012-04-13
6
Medium Priority
?
319 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
6 Comments
 
LVL 101

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 101

Expert Comment

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

mlmcc
0
On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

 
LVL 35

Accepted Solution

by:
James0628 earned 2000 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 35

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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

752 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