NotInList error msg

D

Del

I want to change the error message displayed in Access 2000 when the user
enters a value in a combo box that is not in the list. I've tried the
following code but the system message still appears.

Private Sub SupplierName_NotInList(NewData As String, Response As Integer)
If MsgBox("'" & NewData & "' is not in list. Add?", vbYesNo) = vbYes Then
DoCmd.SetWarnings False
DoCmd.RunSQL "Insert Into tblYourTable (YourFieldName) Values('" & _
NewData & "')"
DoCmd.SetWarnings True
Response = acDataErrAdded
Else
Response = acDataErrContinue
MsgBox "Mate, retype or select something from the list"
End If
End Sub
 
O

Ofer Cohen

I tried your code and it works.

Make sure that you adding that value to the right field that the combo is
bounded to.
That can cause the error to apear, becuase the value added to the wrong field
 
D

Del

Just so I completely understand. If this code works, will I get the
following message when I enter text that isn't on the list?

"The text you entered isn't an item in the list. Select an item from the
list, or enter text that matches one of the listed items."
 
O

Ofer Cohen

I didn't get the message, but as I said if you add this value to the wrong
field you will get this error message.

If you need help with it, Post the SQL of the Combo RowSource,
and n the BoundColumn Property of the combo, what number does it contain
 

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