IF criteria

Ripley

Registered User.
Local time
Today, 06:00
Joined
Aug 4, 2006
Messages
148
How would i go about creating a really really long chain of IF criteria?

I can do it with seperate IF statements, for example:
Code:
If me.form.field1 = "test1" then
msgbox "This Works!"
End If

If me.form.field1 = "test2" then
msgbox "This Works!"
End If

If me.form.field1 = "test3" then
msgbox "This Works!"
End If

etc....

But the criteria i want works, but i get an error message saying the expression is too long:(

I've tried this:

Code:
If me.form.field1 = "test1" or "test2" or "test3" then
msgbox "This Works"
End If

To me this seemed the logical option, but it dosent seem to work. Is there any way to do this?
 
ok sry but that really dosent help lol! can you possibly write me the skeleton code for the example i have above?
 
I don't understand the error you're getting but the reason
>>If me.form.field1 = "test1" or "test2" or "test3" then
doesn't work is because you're not telling it what to compare "test2" or "test3" to.
It would need to be written as
If me.form.field1 = "test1" or me.form.field1 = "test2" or me.form.field1 = "test3" then

You could also write as follows
If me.form.field1 = "test1" then
msgbox "This Works!"
elseif me.form.field1 = "test2" then
msgbox "This Works!"
elseif me.form.field1 = "test3" then
msgbox "This Works!"
End If

The select case structure is as follows
Select Case me.form.field1
Case "test1"
msgbox "This Works!"
Case "test2"
msgbox "This Works!"
End Select

There are other formatting options on the Case statement for including multiple tests on a single line (e.g. Case "test1","test2","test3").
hope this helps
James
 

Users who are viewing this thread

Back
Top Bottom