By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,953 Members | 1,109 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,953 IT Pros & Developers. It's quick & easy.

INPUTBOX not evaluating properly

P: 98
I have declared mUser as a public variable as I need to be able to alter ALL procedures depending on the input.

Option Compare Database
Public mUser As String

I am trying to check if the user types the correct entry. If I enter 'laa' or 'LAA' or 'jg' or 'JG' into my inputbox, although it debugs properly, my IF statement always forces the msgBox display. Why isn't mUser working in my IF statement? thank you for any help!!!

Private Sub Form_Open(Cancel As Integer)

mUser = InputBox("Please sign in: ", "User Sign In", , 5000, 5000)
Debug.Print mUser
Debug.Print Len(mUser)
If mUser <> "JG" Or mUser <> "laa" Or mUser <> "jg" or mUser <> "JG" Then
MsgBox "Incorrect Entry!", vbCritical
'DoCmd.Close
End If
End Sub
Oct 19 '06 #1

✓ answered by NeoPa

You're using OR instead of AND.

Another tip to make things easier is :-

Use UCase() around the response from InputBox then you only have to check against the names once.
This also avoids problems when someone types in 'James'.

Share this Question
Share on Google+
3 Replies


NeoPa
Expert Mod 15k+
P: 31,342
You're using OR instead of AND.

Another tip to make things easier is :-

Use UCase() around the response from InputBox then you only have to check against the names once.
This also avoids problems when someone types in 'James'.
Oct 19 '06 #2

P: 98
Sometimes its the simple things that get us down!!!! thanks!!!
Oct 19 '06 #3

100+
P: 179
Use "UCase" as NeoPa suggested, but also add an ELSEIF statement. It should look like this:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Open(Cancel As Integer)
  2.  
  3. mUser = InputBox("Please sign in: ", "User Sign In", , 5000, 5000)
  4. UCase(mUser)
  5. Debug.Print mUser
  6. Debug.Print Len(mUser)
  7. If mUser <> "JG" Then
  8. MsgBox "Incorrect Entry!", vbCritical
  9. 'DoCmd.Close
  10. Else If mUser <> "LAA"
  11. MsgBox "Incorrect Entry!", vbCritical
  12. 'DoCmd.Close
  13. End If
  14. End Sub
Oct 19 '06 #4

Post your reply

Sign in to post your reply or Sign up for a free account.