How prevent delete of a record ?

  • Thread starter Thread starter David
  • Start date Start date
D

David

I have a datasheet format subform and I am allowing
deletes. However, I need to prevent the delete if there
are linked records in another table. I have coded an ON
DELETE event procedure to do this with a ME.UNDO statement
but it is not working, the records are being deleted.
Is there a proper way to do this?
 
Me.Undo won't work on deletion.

You need to set the Cancel argument of the Event Procedure
to true. There is a sample code in Access VB Help
topic "Delete Event".

HTH
Van T. Dinh
MVP (Access)
 
If database design is your *main* job in the company, tell
whoever decided this that you can't work without the Help
installed and the decision is equivalent to running the
company without SOPs (Standard Operating Procedures).

If the company decides that you still shouldn't have the
Help file and should work at a reduced efficiency due to
lack of proper documentation, tell the CEO who would love
to hear this.

If the CEO agrees with the decision of not installing Help
(equivalent to a huge waste of resources), move on. There
are lots of smarter companies out there.

HTH
Van T. Dinh
MVP (Access)
 
Back
Top