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

If then else formula question 1

Status
Not open for further replies.

lareya

Technical User
Jan 30, 2003
49
US
Okay I have a formula that should be working, but isn't.
here is the formula:

Code:
if {WP_INTRA_OP_02.TOURN_UP1_TIME} <> datetime(1800,01,01,00,00,00) OR
   {WP_INTRA_OP_02.TOURN_DOWN1_TIME} <> datetime(1800,01,01,00,00,00) 
and  {WP_MISC.CODE_17} = 0 or isnull({WP_MISC.CODE_17})  
and {WP_MISC.CODE_20} = 0 or isnull({WP_MISC.CODE_20})  
and {WP_MISC.CODE_18} = 0 or isnull({WP_MISC.CODE_18})  
and {WP_MISC.CODE_19} = 0 or isnull({WP_MISC.CODE_19})  
and {WP_MISC.BUTTON01} = '0' or isnull({WP_MISC.BUTTON01})  
and {WP_MISC.BUTTON02} = '0' or isnull({WP_MISC.BUTTON02})  
then
'Check a Tourniquet Placement Field  ';

This formula checks if there is a time in the tourniquet time field (either the up or down time) then it will check all the placement fields. And if there is NOT any of the placement fields checked, then it should give the error message " Check a Tourniquet Placement Field"

I have 6 fields for placement (like LT arm, RT arm, etc)and 2 of them are not code files, so I have them in the "". They are all checkmark fields, and should either have a 1 or 0 . The problem arises that when I check one of the placement fields, it still gives the error message.

The program I use defaults to this time field for datetime (1800,01,01,00,00,00) which is means that no time or date is in that field.

So why is this not working?

I have a similar formula that works correctly.
Code:
IF  {WP_INTRA_OP_02.TOURN_UP1_TIME} <> datetime(1800,01,01,00,00,00) 
and {WP_INTRA_OP_02.TOURN_DOWN1_TIME} = datetime(1800,01,01,00,00,00) 
 then
     'Check the Tourniquet 1 down time Field'  ELSE 

IF {WP_INTRA_OP_02.TOURN_DOWN1_TIME} <> datetime(1800,01,01,00,00,00) 
and {WP_INTRA_OP_02.TOURN_UP1_TIME} = datetime(1800,01,01,00,00,00) 
 then
     'Check the Tourniquet 1 Up Time Field'

I have doubled checked my field placement codes, and they are the correct fields. I wish there was a way I could step thru my code to see where it is not acting like I think it should.

Any help greatly appreciated.
TIA

Lareya

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Crystal 8.5; SQL database; MS Windows 2K; ORSOS/One Call Hospital Scheduling System v9.3; Huge Newbie to Crystal! Operating Room RN Analyst
 
First, you should set off "or" statements in parens so that it is clear what clauses belong to each other. You also should test for nulls before testing for values in the related field. So try:

if (
{WP_INTRA_OP_02.TOURN_UP1_TIME} <> datetime(1800,01,01,00,00,00) OR
{WP_INTRA_OP_02.TOURN_DOWN1_TIME} <> datetime(1800,01,01,00,00,00)
) and
(
isnull({WP_MISC.CODE_17}) or {WP_MISC.CODE_17} = 0
) and
(
isnull({WP_MISC.CODE_20}) or {WP_MISC.CODE_20} = 0
) and
(
isnull({WP_MISC.CODE_18}) or {WP_MISC.CODE_18} = 0
) and
(
{isnull({WP_MISC.CODE_19}) or WP_MISC.CODE_19} = 0
) and
(
isnull({WP_MISC.BUTTON01}) or {WP_MISC.BUTTON01} = '0'
) and
(
isnull({WP_MISC.BUTTON02}) or {WP_MISC.BUTTON02} = '0'
)
then
'Check a Tourniquet Placement Field '

-LB
 
Thank you so much! That works perfectly! Is there a faq that covers things like you mentioned above? I would love to know more tricks like that!

>>First, you should set off "or" statements in parens so that it is clear what clauses belong to each other. You also should test for nulls before testing for values in the related field. >>

Lareya

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Crystal 8.5; SQL database; MS Windows 2K; ORSOS/One Call Hospital Scheduling System v9.3; Huge Newbie to Crystal! Operating Room RN Analyst
 
I'm not aware of an FAQ on this sort of thing, but if you follow the threads in the CR fora, you will pick up concepts like these pretty quickly.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top