Solved Need help with IF AND OR function

travel4u

New member
Local time
Today, 05:47
Joined
Nov 12, 2017
Messages
15
I have following IF function in Macro (Field3 is text field):
IF [Field01]=1 And [Field2]=0 And [Field3]="12"
Question: [Field3] has 3 valid values: "12" or "1" or "2"
I have tried this in function, but did'n work correctly:
IF [Field01]=1 And [Field2]=0 And [Field3]="12" Or [Field3]="1" Or [Field3]="2"
 
Last edited:
Try
Code:
IF [Field01]=1 And [Field2]=0 And ([Field3]="12" Or [Field3]="1" Or [Field3]="2")
 
BUMMER! :) That came to my mind earlier, but didn't try... IT WORKED PERFECTLY! Thanks.
 
Logical operators have an order of precedence just as arithmetic operators do. Therefore, when you create a compound condition that uses more than one operator, you should use parentheses to ensure that the condition gets evaluated as you intended.

As written, your expression was being evaluated this way:
Code:
IF (  [Field01]=1 And [Field2]=0 And [Field3]="12" )     Or [Field3]="1"       Or [Field3]="2"
 

Users who are viewing this thread

Back
Top Bottom