IF/Then with Multiple Conditions (1 Viewer)

chadbrewyet

New member
Local time
Today, 00:10
Joined
Aug 19, 2014
Messages
9
Looked around and haven't found a satisfactory answer. I'm trying to create an If/Then statement that needs to match to multiple values. My initial thoughs were to create a list but that doesn't seem to work the way I thought it would.

For example:
If Me.Field = 1,2,5, or 8 Then
Do 'X'
Else IF Me.Field = 3,4,6 or 7 THen
Do 'Y'
Else Do 'Z'


I haven't been able to get the syntax to work right. I'd rather not have to do 'Me.Field = 1 or Me.Field = 2, etc.' but if that's the only way to have it work right, then I guess it'll have to do.

Thanks.
 

vbaInet

AWF VIP
Local time
Today, 06:10
Joined
Jan 22, 2010
Messages
26,374
My initial thoughs were to create a list but that doesn't seem to work the way I thought it would.
Talking about your initial thoughts, what kind of list did you make and how did it not work the way it should?
 

chadbrewyet

New member
Local time
Today, 00:10
Joined
Aug 19, 2014
Messages
9
I tried an array with my values in it but could never get the syntax to process the IF/then properly. I've made several changes to the code since beginning so I can't remember exactly how it was coded before and exactly what error it kept throwing.
 

vbaInet

AWF VIP
Local time
Today, 06:10
Joined
Jan 22, 2010
Messages
26,374
Alright. I thought you were talking about a table, because that's what you actually need.
 

JHB

Have been here a while
Local time
Today, 07:10
Joined
Jun 17, 2012
Messages
7,732
Looked around and haven't found a satisfactory answer. I'm trying to create an If/Then statement that needs to match to multiple values...
Did you look at the "Select Case" condition?
 

vbaInet

AWF VIP
Local time
Today, 06:10
Joined
Jan 22, 2010
Messages
26,374
You might be right there J.

If it's an action that needs to be performed following the checks then it's SELECT..CASE.
If it's a value that that should be derived following the checks then a table is required.
 

Users who are viewing this thread

Top Bottom