I have boolean value either class a or class b.. if those given condition are fulfilled then i want to have class a label in my report else class b. but when i inserted below format in formula field then i got error. this is just a sample. plz provide me right syntax and formula for it.. would be very helpful..

if {a<5} || {b<5} || {c<3} || {d<3} then
"Class A"
"Class B"

4 Years
Discussion Span
Last Post by Reverend Jim

The first problem is that is not VB code so the syntax is completely wrong. Please ensure that your code is actually the correct language for the forum.

Next problem - a boolean variable can not be "either class a or class b". It can only be True or False (technically it can also be undefined).

Assuming you have a boolean variable called classA which is True for class a and False for class b (a very bad use of a boolean by the way), your code might look like

lblClass.Text = "Class " & IIF(classA, "A", "B")

You'd be better off having a char variable named classID which has the value "A" or "B" and your code then becomes

lblClass.Text = "Class " & classID

For one thing, if you decide to add classes c, d, etc. you don't have to modify that code at least.

Edited by Reverend Jim


actually i m not asking for vb.net.. i m asking for crystal report. anyway i found out my mistake, it was or instead of ||. thanx for ur response. and another problem is i m not able to use elseif in crystal report. is there any alternative way for elseif..

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.