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

Case Statements in Crystal 3

Status
Not open for further replies.

tc3596

Technical User
Joined
Mar 16, 2001
Messages
283
How do I do case staements in crystal?

In SQL, it would be:

1 = case when @hello = '' then 1
when T.salutation = @hello then 1
else 0
end
1 = case when @numberid = '' then 1
when T.number = @numberid then 1
else 0
end
 
You use the 'Select' statement as follows:

Select {table.field}:
Case "whatever"
Do this
...
Case default
Do this

I don't know if I mucked the exact syntax or not, but if you check the help files and search for 'select case', you'll find it! -rodbac
 
Have you ever tried using the SWITCH function as a alternative for the CASE statement I found it to be easier and les code intensive in Crystal and VB
 
I am using crystal 7. I don't see anything about case statements, or switch statements in the help files. When I input the words "case", "select" or "switch" in records selection, it doesn't show it as a keyword.
 
Case and Switch are V8 functions.

Switch may perform a bit slower if I understand the explanation given at the bottom of the help screen that describes its use. Ken Hamady
On-site custom Crystal Reports Training and Consulting.
Quick Reference Guide to using Crystal in VB.
 
Sorry about that! The only version I've used is 8.5- I should have considered whether older versions had the same capabilities...
 
Thanks all. Actually I created the parameters in access 97. However, (always a catch), when I create my report using a "Standard" Database File, the access 97 query does not appear as a choice. When I use ODBC, I get a "Invalid SQL Statement - Expected "Insert", "Delete", "Procedure", "Select" or "Update" error.
In the access query, I set up the parameters correctly, (I think). It works fine in access. Is there some setting I'm forgetting (ANSI nulls on ODBC setup or something)?
 
This is a select query isn't it. Ken Hamady
On-site custom Crystal Reports Training and Consulting.
Quick Reference Guide to using Crystal in VB.
 
Does it work if you eliminate the parameter in MS Access? Ken Hamady
On-site custom Crystal Reports Training and Consulting.
Quick Reference Guide to using Crystal in VB.
 
If I eliminate the parameter from access, then I still run into the problem of not being able to do the case statements in crystal
 
I am trying to uncover the source of the ODBC error, which may be the parameter itself.
Ken Hamady
On-site custom Crystal Reports Training and Consulting.
Quick Reference Guide to using Crystal in VB.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top