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

Very simple question

Status
Not open for further replies.

finberg

Programmer
Aug 23, 2002
27
UA
I know that the answer is really very simple, but I can't get it.
I maade a procedure Fcheck to make a check for duplication in a table.
I want that when the new data is added in the form, it is checked with this procedure, and if the procedure=True than not allow to add it or delete the added values.
How could it be done?
Thanks
 
Use the before update event of the form.
In that event check if the data witch is about to be added (the data from the form) is already in the table. If it is then return True and call the undo method of the form object to remove the data (Me.Undo) or simply ask the user to change the data.
 
You could also define a primary key or unique index on your table, this way the database will enforce non-duplicates, whether or not you check through custom code like fcheck().

The database will raise an error that you can trap. This is probably a better technique because it protects the table from duplicates in all circumstances, whether you are importing data, entering via form, or entering data directly via the browse.

Mike Pastore

Hats off to (Roy) Harper
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top