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"
else
"Class B"

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.

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..

Sorry. Never used Crystal Rports.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.