I have the following formula, that displays the category if the product does not equal one of 4 Productkeys (354,190,532,430), otherwise it generates a 4 character code by applying a set of rules to the sale, here is the formula :
StringVar Korner := If {DATAPROD.REFPRODKEY} <> [354,190,532,430] then
{@KCat};
StringVar FirstChar := if (Count ({DATAPROD.PRODPKEY}, {DATASALES.SALEPKEY})) >1 then "B" else "A";
StringVar SecChar := if (Count ({DATAPROD.PRODPKEY}, {DATASALES.SALEPKEY})) =1 then "N" else
if {DATAPROD.REFPRODKEY} = 354 then "C" else
if {DATAPROD.REFPRODKEY} = 190 then "E"
else "B";
StringVar ThirdChar := if (Count ({DATAPROD.PRODPKEY}, {DATASALES.SALEPKEY})) =1 then "N" else
if {DATAPROD.REFPRODKEY} = 532 then "G" else "N";
StringVar FourthChar := if (Count ({DATAPROD.PRODPKEY}, {DATASALE.SALEPKEY})) = 1 then "N" else
if {DATAPROD.REFPRODKEY} = 430 then "P" else "N";
If {DATAPROD.REFPRODKEY} <> [354,190,532,430] then '"' + ToText ({@KCat}) + '"' else
'"' + ToText (FirstChar)+totext(SecChar)+totext(ThirdChar)+totext(FourthChar) + '"'
As mentioned, this works fine in one report but gives an error 'the summary/running total field could not be created'. I've re-written this formula step by step - the first part works fine (StringVar Korner := If {DATAPROD.REFPRODKEY} <> [354,190,532,430] then
{@KCat}
the second part (StringVar FirstChar) is when it falls over with the above error. I'm no programmer (despite what tek-tips thinks) so it’s a small miracle the code works in one report! It’s killing me as to why its not working in another. Thanks
StringVar Korner := If {DATAPROD.REFPRODKEY} <> [354,190,532,430] then
{@KCat};
StringVar FirstChar := if (Count ({DATAPROD.PRODPKEY}, {DATASALES.SALEPKEY})) >1 then "B" else "A";
StringVar SecChar := if (Count ({DATAPROD.PRODPKEY}, {DATASALES.SALEPKEY})) =1 then "N" else
if {DATAPROD.REFPRODKEY} = 354 then "C" else
if {DATAPROD.REFPRODKEY} = 190 then "E"
else "B";
StringVar ThirdChar := if (Count ({DATAPROD.PRODPKEY}, {DATASALES.SALEPKEY})) =1 then "N" else
if {DATAPROD.REFPRODKEY} = 532 then "G" else "N";
StringVar FourthChar := if (Count ({DATAPROD.PRODPKEY}, {DATASALE.SALEPKEY})) = 1 then "N" else
if {DATAPROD.REFPRODKEY} = 430 then "P" else "N";
If {DATAPROD.REFPRODKEY} <> [354,190,532,430] then '"' + ToText ({@KCat}) + '"' else
'"' + ToText (FirstChar)+totext(SecChar)+totext(ThirdChar)+totext(FourthChar) + '"'
As mentioned, this works fine in one report but gives an error 'the summary/running total field could not be created'. I've re-written this formula step by step - the first part works fine (StringVar Korner := If {DATAPROD.REFPRODKEY} <> [354,190,532,430] then
{@KCat}