Link to home
Create AccountLog in
Avatar of TimJar
TimJarFlag for United States of America

asked on

If Statement with multiple conditions

I want to call a procedure as long as strSearchWord does not equal the following words or charactors: project, contact, -, &, @

This code is not working:
if not strSearchWord = "project" or not strSearchWord = "@" or not strSearchWord = "-" then

I don't think I'm approaching this right
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

How about this:

      If InStr(1, strSearchWord, "project") > 0 Then Exit Function
      If InStr(1, strSearchWord, "contact") > 0 Then Exit Function
      If InStr(1, strSearchWord, "-") > 0 Then Exit Function
      If InStr(1, strSearchWord, "&") > 0 Then Exit Function
      If InStr(1, strSearchWord, "@") > 0 Then Exit Function
       
      MsgBox "Good to go - call function"

mx
ASKER CERTIFIED SOLUTION
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of TimJar

ASKER

You're the man