validation rule on combo box

K

KIT LAU

Hi,

I would like to create a validation rule on the values of
the combo box. If the data inputted is not found in the
rowsource of the combo box, error messages will be popped
up.

How can I do that?

Thanks for your help.

Kit Lau
 
G

Gerald Stanley

This is done for you when you set the LimitToList property
to Yes.

Hope That Helps
Gerald Stanley MCSD
 
V

Van T. Dinh

In addition to Gerald's answer, use the NotInList Event of the ComboBox if
you want a custom message rather than the default Access message.

Check Access VB Help on the NotInList Event of ComboBox.
 
K

KIT LAU

Thanks. It worked. But how can I bypass the system error
message "The text you entered isn't an item in the list"
and I want to customize the message.

KIT LAU
 
V

Van T. Dinh

See Access VB Help on the NotInList Event / Event Procedure.

The code should be something like:

****
Private Sub Combo0_NotInList(NewData As String, Response As Integer)
' Display custom dialog box.
MsgBox "Sorry, not in list.", vbOKOnly, "Not In List!"
' Suppress default Delete Confirm dialog box.
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