using "OR" in OPEN event if then statement

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have the following code on the open event of my switchboard and it makes
the vbe screen blink and act strange. I've had to go to a nested if but this
just doesn't look efficient. Any suggestions? I've tried several formats
for the first line but none have worked. Thanks for the help

Problem Code:
If fOSUserName <> 953126 or <>416503 Then
DoCmd.OpenForm "frmInactiveShutDown", , , , , acHidden
End If

Code that is working:
If fOSUserName <> 953126 Then
If fOSUserName <> 416503 Then
DoCmd.OpenForm "frmInactiveShutDown", , , , , acHidden
End If
End If
 
Hey Steve, try this:

If fOSUserName <> 953126 or fOSUserName <> 416503 Then
DoCmd.OpenForm "frmInactiveShutDown", , , , , acHidden
End If

You can also use the Select Case Statement.
 
I had already tried that and it didn't work but using the Case If structure
is a good idea and I think that will be the best solution.
 
SteveR said:
I have the following code on the open event of my switchboard and it makes
the vbe screen blink and act strange. I've had to go to a nested if but this
just doesn't look efficient. Any suggestions? I've tried several formats
for the first line but none have worked. Thanks for the help

Problem Code:
If fOSUserName <> 953126 or <>416503 Then
DoCmd.OpenForm "frmInactiveShutDown", , , , , acHidden
End If

Code that is working:
If fOSUserName <> 953126 Then
If fOSUserName <> 416503 Then
DoCmd.OpenForm "frmInactiveShutDown", , , , , acHidden
End If
End If


Those two blocks of code are not equivalent.

You want an AND instead of OR.

I have no idea how either of those can can cause the screen
to act strange.
 
Back
Top