Customizing an error message

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

Guest

I have a combo box that has a Row Source that is a table. If the user enters
in a value that is not in the table, I want to prohibit users behavior to
avoid an error message concerning a PK issue. What I want the user to do is
enter new values via the correct form. To prohibit this error, in the combo
box I set the properties in Limit to List to "Yes". This works giving a more
comprehendable message, but I would like to replace the error message with
instructions, instructing the user how to add the value to the list using the
correct form. How can I do this?
 
in form design view, select the combo box control and, in the Properties
box, click the Event tab. click on the On Not in List "line", and press F1.
Access will open Help to the OnNotInList Property topic. click on the
Applies To option and select ComboBox Object. in that topic, click on the
Events option and select NotInList Event. read through the topic; it
explains how the event works, and how you can use it to add items to a
droplist "on the fly". in the code example, you can replace the following
line

ctl.RowSource = ctl.RowSource & ";" & NewData

with an OpenForm command, to add the value to your table, as

DoCmd.OpenForm "FormName", , , , , acDialog

or you can use very simple code in the NotInList event procedure that simply
shows a message box, as

Response = acDataErrContinue
MsgBox "put your message here"

hth
 
Tina,

Your suggestion was excellent! Far better than the road I was headed on. I
salute your talent and thank you for your help!
--
Thanks,

Dennis


tina said:
in form design view, select the combo box control and, in the Properties
box, click the Event tab. click on the On Not in List "line", and press F1.
Access will open Help to the OnNotInList Property topic. click on the
Applies To option and select ComboBox Object. in that topic, click on the
Events option and select NotInList Event. read through the topic; it
explains how the event works, and how you can use it to add items to a
droplist "on the fly". in the code example, you can replace the following
line

ctl.RowSource = ctl.RowSource & ";" & NewData

with an OpenForm command, to add the value to your table, as

DoCmd.OpenForm "FormName", , , , , acDialog

or you can use very simple code in the NotInList event procedure that simply
shows a message box, as

Response = acDataErrContinue
MsgBox "put your message here"

hth
 
Back
Top