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

Select Case statement

Status
Not open for further replies.

RPOC

IS-IT--Management
Jun 17, 2003
44
US
I am using Crystal 8.5 and am trying to do a nested case statement. I cannot seem to get it to work and am not sure if it can be done. I was looking at a 8.5 book and there is no clear descriptive way of indicating the end of one select case and starting another.

the code looks as follows.
Select {inventory_transact_table.transaction_type_code}

Case "1":
"Receive"
Case "2":
If ({inventory_transact_table.v_pick_up_type_code} = "1" ) AND
({inventory_transact_table.v_exception_dose_code} = "N" or isnull({inventory_transact_table.v_exception_dose_code} ) )then
"DOS"
Else If {inventory_transact_table.v_pick_up_type_code} = "1" Then
"DOS-EXC"
Else If {inventory_transact_table.v_exception_dose_code} = "N" Then
"T/O"
Else
"T/O-EXC"
Case "3":
If IsNull({inventory_transact_table.LINK_TO_TRANSFER_INV}) Then
"ADJ"
Else If {inventory_transact_table.amount} < 0 Then
"Transfer Out"
Else
"Transfer In"
Case "4":
if isnull({inventory_transact_table.PATID}) then
"PP-RTI"
else
"RTI"
Case "5":
"Open"
Case "6":
"Close"
Case "7":
if isnull({inventory_transact_table.PATID}) then
"PP-Spill"
else
"Spill"
******end of code*************
under the case 2 I would like to add the following after the else , t/o but not part of the if statement.

Select {inventory_transact_table.v_PP_current_status_code}

CASE "5","6":
"PP-Pouredx"


Can this be done and if so how, Any Help would be appreciated.
 
Dear RPOC;

Is this what you are trying to accomplish?

Case "2":
(
If ({inventory_transact_table.v_pick_up_type_code} = "1" ) AND
({inventory_transact_table.v_exception_dose_code} = "N" or isnull({inventory_transact_table.v_exception_dose_code} ) )then
"DOS"
Else If {inventory_transact_table.v_pick_up_type_code} = "1" Then
"DOS-EXC"
Else If {inventory_transact_table.v_exception_dose_code} = "N" Then
"T/O"
Else
"T/O-EXC";
Select {inventory_transact_table.v_PP_current_status_code}

CASE "5","6":
"PP-Pouredx"
)

Notice the parenthesis and the semicolor after "T/O-EXC" and the close parenthesis after "PP-Pouredx"

This will save with no errors .. but I didn't have time to set up a test for the logic being correctly returned.

regards,

ro

Rosemary Lieberman
rosemary-at-microflo.com, Microflo provides expert consulting on MagicTSD and Crystal Reports.

You will get answers more quickly if you read this before posting: faq149-3762
 
This is what I want to do. When I enter the information with the way it is laid out I am getting a message that I need to enter an additional ")". I find this strange because when I do not enter any of the additional paranthesis as suggested I do not get the message. I thought this was me so I then cut and pasted your code that worked into my code and recieved the same message. When no paranthesis are there I do not get a message.
.
 
Dear RPOC,

So sorry, forgot you are 8.5 CR and I was using CR 10 to test this for you.

There is a known bug in CR 8.5 (they fixed it in CR 10) that anytime you used an open paren in the statement, they required two closing parens ... don't know why, but it works perfectly if you add that extra closed parenthesis.

I know, it doesn't make sense but it is what it is... I would suggest you put a little suppressed text box in the header of the report: REMINDER: Report contains case statement with parens ... when upgrading to CR 10 remove extra right paren from formula.

That way ... it won't catch you again later.

regards,

ro

Rosemary Lieberman
rosemary-at-microflo.com, Microflo provides expert consulting on MagicTSD and Crystal Reports.

You will get answers more quickly if you read this before posting: faq149-3762
 
Thanks for the information. I thought it might be software related.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top