Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conditionalize the 3 Formula Trick 1

Status
Not open for further replies.

RSchnable

MIS
Jan 26, 2010
18
US
Hello all,

I have a Crystal Report that totals orders for the month. I used the following code
Code:
if {BAQReportParameter.Check02} = false AND {BAQReportParameter.Check03} = false 
then {BAQReportResult.OrderDtl.ProdCode} = "GUN" 
or {BAQReportResult.OrderDtl.ProdCode} = "TRE"
or {BAQReportResult.OrderDtl.ProdCode} = "BORE"
or {BAQReportResult.OrderDtl.ProdCode} = "CON"
or {BAQReportResult.OrderDtl.ProdCode} = "GM"
or {BAQReportResult.OrderDtl.ProdCode} = "HONE"
or {BAQReportResult.OrderDtl.ProdCode} = "SPA"
or {BAQReportResult.OrderDtl.ProdCode} = "SUB"
or {BAQReportResult.OrderDtl.ProdCode} = "PDN"
or {BAQReportResult.OrderDtl.ProdCode} = "PDR"
or {BAQReportResult.OrderDtl.ProdCode} = "TURN"

else if {BAQReportParameter.Check02} = TRUE
then {BAQReportResult.OrderDtl.ProdCode} = "GUN" 
or {BAQReportResult.OrderDtl.ProdCode} = "BORE"
or {BAQReportResult.OrderDtl.ProdCode} = "CON"
or {BAQReportResult.OrderDtl.ProdCode} = "GM"
or {BAQReportResult.OrderDtl.ProdCode} = "HONE"
or {BAQReportResult.OrderDtl.ProdCode} = "SPA"
or {BAQReportResult.OrderDtl.ProdCode} = "SUB"
or {BAQReportResult.OrderDtl.ProdCode} = "TRE"
or {BAQReportResult.OrderDtl.ProdCode} = "TURN"

else if {BAQReportParameter.Check03} = TRUE 
then {BAQReportResult.OrderDtl.ProdCode} = "PDN"
or {BAQReportResult.OrderDtl.ProdCode} = "PDR"
to conditionalize it before. But due to a change in the way we report, I had to change my running total field, and was forced to switch to using the 3 formula trick for my running total.

I essentially want to apply the above condtions to the following
Code:
WhilePrintingRecords;

NumberVar Total;

Total:= Total+{@OrdTotal}

Thanks in advance for any help, and I apologize if I've missed any important details.
 
What is the content of {@OrdTotal}? Where are you displaying the result? Is the variable Total intended to be displayed in the Report footer?

-LB
 
Yes, the Total variable is being displayed in the report footer section.

The following is the content of {@OrdTotal}
Code:
IF OnLastRecord THEN ({BAQReportResult.OrderDtl.OrderQty} * {BAQReportResult.OrderDtl.UnitPrice})

ELSE IF {BAQReportResult.OrderHed.OrderNum} <> Next({BAQReportResult.OrderHed.OrderNum}) AND {BAQReportResult.OrderHed.OrderNum} <> PREVIOUS({BAQReportResult.OrderHed.OrderNum})   THEN
({BAQReportResult.OrderDtl.OrderQty} * {BAQReportResult.OrderDtl.UnitPrice}) + {BAQReportResult.OrderHed.TotalMisc}
ELSE IF {BAQReportResult.OrderHed.OrderNum} = NEXT({BAQReportResult.OrderHed.OrderNum}) AND {BAQReportResult.OrderDtl.OrderLine}= 1 OR {BAQReportResult.OrderHed.OrderNum} = PREVIOUS({BAQReportResult.OrderHed.OrderNum}) AND {BAQReportResult.OrderDtl.OrderLine}= 1 THEN
({BAQReportResult.OrderDtl.OrderQty} * {BAQReportResult.OrderDtl.UnitPrice}) + {BAQReportResult.OrderHed.TotalMisc}
ELSE IF {BAQReportResult.OrderHed.OrderNum} = NEXT({BAQReportResult.OrderHed.OrderNum}) AND {BAQReportResult.OrderDtl.OrderLine}> 1 OR {BAQReportResult.OrderHed.OrderNum} = PREVIOUS({BAQReportResult.OrderHed.OrderNum}) AND {BAQReportResult.OrderDtl.OrderLine}> 1 THEN
({BAQReportResult.OrderDtl.OrderQty} * {BAQReportResult.OrderDtl.UnitPrice})
 
It seems like it would make more sense to use your conditions in the record selection formula, but I guess you could change your accumulation formula to:

whileprintingrecords;
numbervar total;
if
(
(
{BAQReportParameter.Check02} = false AND
{BAQReportParameter.Check03} = false and
{BAQReportResult.OrderDtl.ProdCode} in["GUN","TRE","BORE","CON","GM","HONE","SPA","SUB","PDN","PDR","TURN"]
) or
(
{BAQReportParameter.Check02} = TRUE and
{BAQReportResult.OrderDtl.ProdCode} in ["GUN","BORE","CON","GM","HONE","SPA","SUB","TRE","TURN"]
) or
(
{BAQReportParameter.Check03} = TRUE and
{BAQReportResult.OrderDtl.ProdCode} in ["PDN","PDR"]
)
) then
total := total + {@OrdTotal};

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top