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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crystal Reports 7 in VB6 - Error in formula please help 2

Status
Not open for further replies.

JonAtBits

Programmer
Apr 11, 2005
3
ZA
Hi,

I have written the followinf formula to try and calculate a sales rep commission amout in Crystal Reports 7 used via Visual Basic 6. When I try and save the following formula the program tells me that a 'Boolean is required here' and flags the last zero (0) character in the formula. What have I done wrong? Please help:


------------------code snippet----------------------

//Calculate the difference between the Sell Price and the KeyPak Price
//and the Commision amount now.
Global numberVar KPSPDifference := {ado.sellprice} - {ado.price/unit};
Global numberVar KPCommAmount := ({ado.price/unit} * (10/100));
Global numberVar KPCommission := 0;

//If we have a regular record then simply pass through the commission value from SQL
if {ado.Type} = 0 Then
//Extract commission from sql
{ado.comm}

//If we have a Manual Invoice type then calculate the commission
else
//If the selling price is larger than the unit price
if {ado.sellprice} > {ado.price/unit} then

//If the difference is greater than or equal to 10% of the unit price.
if KPSPDifference >= KPCommAmount then
KPCommission = KPCommission + KPCommAmount

else
//Else commission is the difference between the cost and selling price.
KPCommission = KPCommission + KPSPDifference
else
//Selling price is less than KeyPak price
//so there can be no commission. Commission is 0.
0


------------------code snippet----------------------

Many thanks in advance.

JonAtBits
 
You have no explicit outcome to your formula in the segment:
//If the difference is greater than or equal to 10% of the unit price.
if KPSPDifference >= KPCommAmount then
KPCommission = KPCommission + KPCommAmount

else
//Else commission is the difference between the cost and selling price.
KPCommission = KPCommission + KPSPDifference


So the structure is:
if {ado.sellprice} > {ado.price/unit} then
no outcome
else
0

I am guessing that in this situation the first outcome defaults to 'true' and therefore requires a boolean as the other outcome. But really it is not the 'else' outcome that needs to be fixed.



 
KPCommission = KPCommission

should be

KPCommission := KPCommission

Note the missing colon


Bob Suruncle
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top