How do you use "Not In List" Event

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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

If not a valid selection an error message.
 
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
 
Thank you very much for your asssitance
The code works well.

Ileana
 
Can Access default error message be turn off?

"The text you entered isn't an item in this list
 
I can't see your code, but in the NotInList event, the line:

Response = acDataErrContinue

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

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