I have the following code in one of my formula fields
StringVar KeyValue ;
StringVar FirstChar ;
StringVar SecChar ;
StringVar ThirdChar;
StringVar FourthChar ;
If {Product.Itemkey} <> [354,190,532,430] then
KeyValue := {@KeyValue};
The idea of this code is to generate a code dependant on the items (identified by PRODUCT.ITEMKEY) sold within in one 'Sale'(identified by SALE.SALEKEY) to show a pattern of what is bought with what. If the customer didn't buy one of the following product keys (354, 190, 532, 430) then the report displays the result of another formula field (@KeyValue) otherwise I need to build up a 4 character code using the following IF statements dependant on the product key :-
if (Count ({Product.productkey}, {Sale.Salekey})) >1 then
FirstChar := "B"
else
FirstChar := "A";
if (Count ({Product.productkey}, {Sale.Salekey})) = 1 then
SecChar := "N"
else if {Product.ItemKEY} = 354 then
SecChar := "C"
else if {Product.ItemKEY} = 190 then
SecChar := "E"
else
SecChar := "B" ;
if (Count ({Product.productkey}, {Sale.Salekey})) =1 then
ThirdChar := "N"
else if {Product.ItemKEY} = 532 then
ThirdChar := "G"
else
ThirdChar := "N";
if (Count ({Product.productkey}, {Sale.Salekey})) = 1 then
FourthChar := "N"
else if {Product.itemKEY} = 430 then
FourthChar := "P"
else
FourthChar := "N";
Then displayed using the following :-
If {Product.itemKEY} <> [354,190,532,430] then
ToText ({@KeyValue})
else
'"' + ToText (FirstChar)+totext(SecChar)+totext(ThirdChar)+totext(FourthChar) + '"' ;
This only works per item sold it needs to calculate the code when all items sold within that one sale is taken into account. I'm guessing I need to somehow tell crystal to read in all product keys (for each Sale (I'm already grouping by Sale.Salekey)) then generate the code.
I've been playing with this for a while and need some guidance. As always any help is much appreciated.
StringVar KeyValue ;
StringVar FirstChar ;
StringVar SecChar ;
StringVar ThirdChar;
StringVar FourthChar ;
If {Product.Itemkey} <> [354,190,532,430] then
KeyValue := {@KeyValue};
The idea of this code is to generate a code dependant on the items (identified by PRODUCT.ITEMKEY) sold within in one 'Sale'(identified by SALE.SALEKEY) to show a pattern of what is bought with what. If the customer didn't buy one of the following product keys (354, 190, 532, 430) then the report displays the result of another formula field (@KeyValue) otherwise I need to build up a 4 character code using the following IF statements dependant on the product key :-
if (Count ({Product.productkey}, {Sale.Salekey})) >1 then
FirstChar := "B"
else
FirstChar := "A";
if (Count ({Product.productkey}, {Sale.Salekey})) = 1 then
SecChar := "N"
else if {Product.ItemKEY} = 354 then
SecChar := "C"
else if {Product.ItemKEY} = 190 then
SecChar := "E"
else
SecChar := "B" ;
if (Count ({Product.productkey}, {Sale.Salekey})) =1 then
ThirdChar := "N"
else if {Product.ItemKEY} = 532 then
ThirdChar := "G"
else
ThirdChar := "N";
if (Count ({Product.productkey}, {Sale.Salekey})) = 1 then
FourthChar := "N"
else if {Product.itemKEY} = 430 then
FourthChar := "P"
else
FourthChar := "N";
Then displayed using the following :-
If {Product.itemKEY} <> [354,190,532,430] then
ToText ({@KeyValue})
else
'"' + ToText (FirstChar)+totext(SecChar)+totext(ThirdChar)+totext(FourthChar) + '"' ;
This only works per item sold it needs to calculate the code when all items sold within that one sale is taken into account. I'm guessing I need to somehow tell crystal to read in all product keys (for each Sale (I'm already grouping by Sale.Salekey)) then generate the code.
I've been playing with this for a while and need some guidance. As always any help is much appreciated.