Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Key Violation Errors

Status
Not open for further replies.

Turb

Technical User
Feb 11, 2003
154
US
Hi all!
I was wondering if someone could help me out.
I have a field of my table set for "no duplicates"; my question is this: is there a way I can have Access open a form upon erroring for a key violation?
The error Access brings up covers multiple possible problems, I would like to create and have opened on this error a form of my own making (LARGE and RED), but I can't find a "code" number for this particular error.
Any help would be appreciated!

Ind. Engineering Tech.
 
Have a look at the Error event procedure of the forms.
If you want to prevent dup key creation attempts you may consider the DLookUp function in the BeforeUpdate event procedure of the key control.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PHV,
Thank you for responding!
I'm not sure what you mean.
Perhaps I should explain further.
My form is 95% unbound with a SQL query to save the forms textbox contents (this function runs off a command button in the form header). Under the same command button and in the same "Event Procedure" is a print command. The table the SQL query saves to has two "required" fields. The two text boxes that these fields correspond to are highlighted in yellow and the form has a disclaimer in the header to tell users that these fields are required. Even with this, they sometimes try to save the forms contents without filling in the required fields and really don't have any idea what the Access error means when it tells them "Microsoft Access can't append all the records in the append query" so they continue and print the form even though the data is not being saved in the table.
I would like to create a more specific warning form or a perhaps a custom VB message box that will popup in place of this error message to warn the users not to continue, but I cannot find the error code for this particluar error message and am not sure how I would code it.

Ind. Engineering Tech.
 
Why not simply apply your validation rules with appropriate messages BEFORE inserting the data ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PHV,
Doesn't that kind of rank up there with placing the warning in bright yellow right at the top of the form and highlighting the required text boxes?
The users see it, but still ignore it.
I guess I need some way of "error proofing" (this seems more politically correct than "idiot proofing") the data entry on this form. I thought to do this as they tried to save the data would be more appropriate than giving them another warning for them to ignore.

Ind. Engineering Tech.
 
do this as they tried to save the data
It's exactly what I suggested.
Have a look at the If instruction, the SetFocus method and the Exit Sub instruction.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top