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

IF Question

Status
Not open for further replies.

Sadukar

Technical User
Feb 19, 2003
159
IE
Hi All

Is it possible to do an IF using multiple queries.

For example:
IF Textbox1 = "Report 1" or Report 2" or "Report 3" Then
msgbox "Ok"
Else
End if

This does not work.

Any suggestions on how to do this?

Thanks
S.
 
Yes it is possible you are just doing it wrong. Do this:

IF Textbox1 = "Report 1" or Textbox1 = Report 2" or Textbox1 = "Report 3" Then
msgbox "Ok"
Else
End if

I'm not sure what the technical explanation for this is but you have to repeat the conditions explicitly.

Hope thats clear

MrBelfry
 
Well for the technical explanation :

a If statement needs boolean expressions ( True or False)
and the AND or OR evaluate boolean expressions so if you write something like :

[tt]IF Textbox1 = "Report 1" or "Report 2" or "Report 3" Then [/tt]
the program assumes that "Report 2" and "Report 3" are boolean expression(but it's not the case) and that explain why you need to repeat the [tt]textbox1 = "..."[/tt]




jul ^_^
"Computer Science is no more about computers than astronomy is about telescopes"
E. W. Dijkstra.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top