Solved

set variables in Crystal Reports XI

Posted on 2012-04-13
6
308 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
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 …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

895 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

15 Experts available now in Live!

Get 1:1 Help Now