Is there a way to override the MS error messages in a form?

  • Thread starter Thread starter Amit
  • Start date Start date
A

Amit

Hi,

In a combo-box in a form, I'd like to display a specific
message when a user types in a text which is not in the
list, instead of the message displayed by MS Access ("The
text you entered isn't an item in the list...."). How can
I do that?

I did try adding a macro with a specific error message in
the "NotInList" for the Combobox, but I got BOTH the
messages - the one for macro, and then followed by the MS
Access error message.

I have the "Limit to List" property set to 'Yes.'

TIA.

-Amit
 
I use the below inthe forms On_Error property

If DataErr = 2237 Then
Response = acDataErrContinue
strMsg = "Please make a selection " _
& "from the list!"
MsgBox strMsg
End If
 
Amit said:
Hi,

In a combo-box in a form, I'd like to display a specific
message when a user types in a text which is not in the
list, instead of the message displayed by MS Access ("The
text you entered isn't an item in the list...."). How can
I do that?

I did try adding a macro with a specific error message in
the "NotInList" for the Combobox, but I got BOTH the
messages - the one for macro, and then followed by the MS
Access error message.

I have the "Limit to List" property set to 'Yes.'

TIA.

-Amit

You need to use a VBA event procedure, rather than a macro. In the
event procedure, after displaying your own message, set the procedure's
Response argument to the defined constant acDataErrContinue. It might
look like this, in its simplest form:

Private Sub Combo0_NotInList(NewData As String, Response As Integer)

MsgBox "Please enter only items from the list."
Response = acDataErrContinue

End Sub
 
Back
Top