userform help

G

Gary Keramidas

can someone tell me why i get the message box no matter what i type in? if i
only use 1 condition, it works, as soon as i add the second, nothing works.

If UCase(Trim(Me.LSite.Value)) <> "M" Or _
UCase(Trim(Me.LSite.Value)) <> "N" Then
Me.LSite.SetFocus
MsgBox "Please Check Site"
Exit Sub
End If
 
J

JE McGimpsey

Do a little truth table:

Entry <>"M" <>"N" <>"M" Or <>"N"

M FALSE TRUE TRUE
N TRUE FALSE TRUE
A TRUE TRUE TRUE

I suspect your want "And" instead of "Or"

Entry <>"M" <>"N" <>"M" And <>"N"

M FALSE TRUE FALSE
N TRUE FALSE FALSE
A TRUE TRUE TRUE
 
B

Bob Phillips

Because your test drives it that way.

If it is equal to M, it will pass the <> "N" test
If it is equal to N, it will pass the <> "M" test
If neither N nor M, it will pass the <> "M" test

Are you sure you don't mean AND instead of OR


--

HTH

RP
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top