IF statement...Range?

lipin

Registered User.
Local time
Today, 11:26
Joined
May 21, 2002
Messages
149
I would like a text box to show a value in another text box based on the code a user selects in a combo box. What is the syntax for an IF statement if you have a range of a few choies.
Like: IF txtCode = ["E", "ED", "J"]
THEN ....

ELSE IF txtCode = ["MT","SF","B","BK"]
THEN .....

END IF
I am getting syntax errors trying to express the range of choices
E ED & J

Thanks a lot.
 
Have you tried makeing it an OR statement, i.e

IF txt.string = "E" OR "EJ" or "J" Then .....

ElseIF txt.string = "A" OR "string" Then ....

Else ......

End If


-Al
 
afloyd, That syntax is incorrect.

You need to repeat the field name for each OR

IF txtCode = "E" OR txtCode = "ED" OR txtCode = "J" Then

A simplified syntax (and prefered if you have more than 2 choices) is:

IF txtCode IN ("E", "ED", "J") Then
 

Users who are viewing this thread

Back
Top Bottom