Need Help Creating a Friendly Error Message

  • Thread starter Thread starter Jeff
  • Start date Start date
J

Jeff

I am currently stuck on a problem with trying to create a friendly error
message to instruct users to input a non-duplicate item in a combo box.
Specifically, I want users to input a phone number type (i.e., home, work,
fax, etc.) using a combo box and there may only be one such "type" for every
"publisherID" (found in another field).



I have been able to successfully create an index that checks for this
condition using the field names: "PhoneTypeID" & "PublisherID" Everything
works correctly on the form except that I can't figure out how to change the
default error message which states:



"The changes you requested to the table were not successful because they
would create duplicate values in the index, primary key, or relationship.
Change the data in the field or fields that contain duplicate data, remove
the index, or redefine the index to permit duplicate entries and try again."



I don't want this horribly long and confusing message to appear and would
rather something like "That phone type has already been used for this
publisher, please select another type." In addition, I want the focus to be
returned back to the PhoneTypeID control.



I know that there must be someway to do this but I haven't found an answer.
Any ideas? Thanks.
 
DoCmd.SetWarnings (True or False) turns the messages on or off. Be sure to
turn them back on when done.
You will need to use an event, usually BeforeUpdate to check and see if
there is a duplicate, then putup the warning and move back to the field.
 
Back
Top