Message box

  • Thread starter Thread starter Alex Martinez
  • Start date Start date
A

Alex Martinez

Hi,

I need some help on my If statement. I have a field call Branch in my form
that is in a combo box. If the user inputs a different branch number I want
to have a dialog error message box showing that the user inputed the wrong
branch number. It seems to work the only problem is after the user re-input
the branch number after receiving the error message I still get the error
message. What gives? Any help will be appreciated. Thank you.



Private Sub Form_BeforeUpdate(Cancel As Integer)

'If Me.[Branch] <> "007" or "008" or "009" or "111" or "222" Then
'Cancel = True
'MsgBox "Incorrect Branch Number"

End Sub
 
Hi,

I need some help on my If statement. I have a field call Branch in my form
that is in a combo box. If the user inputs a different branch number I want
to have a dialog error message box showing that the user inputed the wrong
branch number. It seems to work the only problem is after the user re-input
the branch number after receiving the error message I still get the error
message. What gives? Any help will be appreciated. Thank you.

Private Sub Form_BeforeUpdate(Cancel As Integer)

'If Me.[Branch] <> "007" or "008" or "009" or "111" or "222" Then
'Cancel = True
'MsgBox "Incorrect Branch Number"

End Sub

Wrong event.

Set the combo box Limit to List property to Yes.
Code the NotInList event:

MsgBox "Incorrect Branch Number." & vbNewLine & "Renter the branch
number."
Me![ComboName] = Null
Response = acDataErrContinue

By setting the Combo LimitToList to Yes, only branch numbers already
in the table will be accepted.
 
Well, your code is all commented out, so it's not doing anything at all, but
even if it wasn't commented out, it wouldn't work.

If Me.[Branch] <> "007" or "008" or "009" or "111" or "222" Then

isn't valid. You need to use

If Me.[Branch] <> "007" And Me.[Branch] <> "008" And
Me.[Branch] <> "009" And Me.[Branch] <> "111" And
Me.[Branch] <> "222" Then
 

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

Back
Top