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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting rid of MS Access Error Messages WRT: Indexes disallowing Dupes

Status
Not open for further replies.

lblack

Programmer
Mar 25, 1999
3
IE
How do I go about getting rid of the standard error message which comes up when something violates an index. "Index violates the primary key indexes, etc etc" or something along those lines.<br>
<br>
I have indexes set up on several tables to disallow duplicates, but though I've changed the onerror value of the forms to which the tables are linked, I now simply have TWO error messages coming up: My own and MS Access.<br>
<br>
I've tried setting warnings off but to no avail. I though the OnError would interrupt any Access messages.<br>
<br>
Please note, these are occurring on subforms not main ones.<br>
<br>
Thank you<br>
Liam<br>

 
I don't know if you can turn the access error messages off, but you could put your own validation in to make sure that the record is valid before you let access try to add it.<br>
<br>
Put some code behind the BeforeUpdate event in your form. The code should check to make sure the record does not violate any of the indexes, and if it does you can show an error message and cancel the update.<br>
<br>
This code will be invoked when a user adds a new record or tries to change an already existing one. One thing to watch out for is that if the user is changing a record and then tries to save it, you may end up comparing the record against itself which would mean that you will always find a duplicate! When doing this kind of thing, I open a recordset if I'm doing a few checks, and I use a where clause to exclude the current record.<br>
<br>
Hope this helps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top