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

If statement syntax problem

Status
Not open for further replies.

trezlub

Programmer
May 2, 2003
67
0
0
GB
How on earth (using Crystal Syntax) do you achieve the most mundane task of having multiple lines of logic within each section of an IF statement? I always seem to get the error:

The remaining test does not appear to be part of the formula.

I am attempting to add a formula with an IF statement in the form:

If DatabaseField <> someValue then
Do task 1
Do task 2
else
Do task 3
Do task 4.



Actual code being used looks like this:

if {sp_InvoiceOneIntroducer.int_Name} <> Intr then

{sp_InvoiceOneIntroducer.fee_User1}
{sp_InvoiceOneIntroducer.fee_User2_5}
else
{sp_InvoiceOneIntroducer.fee_User6up};

Intr is a currencyVar
 
You might try using:

if {sp_InvoiceOneIntroducer.int_Name} <> Intr then
(
{sp_InvoiceOneIntroducer.fee_User1};
{sp_InvoiceOneIntroducer.fee_User2_5};
)
else
{sp_InvoiceOneIntroducer.fee_User6up};


But keep in mind that - at least as far as I know - your first branch (after 'then') will return {sp_InvoiceOneIntroducer.fee_User2_5} and ignore/overwrite the preceeding statement.
 
ok crystalvictim, thanks for that. I can see why you have given yourself the username you have. Crystal logic seems very clumsy to me
 
in fact - considiering other problems - this issue seems quite comprehensible: commands are terminated with a ';' and the brackets are needed to tell crystal that a whole block is to be processed (begin - end in other languages would be a similar construction).

Regarding the other point I mentioned, you have to remember that formulas have been designed to return a certain value, to display a string or something like that.
So if your intention was to display both fields, you should be able to accomplish this by changing the statement into:
{sp_InvoiceOneIntroducer.fee_User1} & ' ' & {sp_InvoiceOneIntroducer.fee_User2_5};
This should concatenate both fields and return this 'value'.
 
I was not aiming to produce two values from the formula, it was just a dodgy example I suppose. Anyway, you have helped me out so thanks for your time.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top