How do you use "Not In List" Event

I

iholder

I would like to validate if the user made a valid selection from combo list
box.

If not a valid selection an error message.
 
M

Marshall Barton

iholder said:
I would like to validate if the user made a valid selection from combo list
box.

If not a valid selection an error message.


If you can live with the fairly good default message, all
you have to do is set the combo box's LinitToList property
to Yes.

There are two ways to provide your own message along with
undoing the invalid entry. The recommended way is to set
the combo box's LimitToList property to Yes and use the
NotInList event with this kind of code in the event
procedure:

MsgBox "You must select an item from the list"
Me.Combo0.Undo
Response = acDataErrContinue

For completeness, the obscure way is to set the LimitToList
property to No and use the combo box's BeforeUpdate event:

If Me.Combo0.ListIndex = -1 Then
MsgBox "You must select an item from the list"
Me.Combo0.Undo
Cancel = True
End If
 
I

iholder

Can Access default error message be turn off?

"The text you entered isn't an item in this list
 
M

Marshall Barton

I can't see your code, but in the NotInList event, the line:

Response = acDataErrContinue

is supposed to do that.
 
A

Anne

Go to Visual Basic.Go to Tools, Options, General tab. Change check mark on
error Trapping to "Break on Unhandled Errors".
 
Top