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

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
 
G

Gina Whipp

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
 
D

Dirk Goldgar

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
 

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