Capture Delete event

J

jnew

Sorry about previous post. I hit Enter too quickly.

I have a subform based on a table with a "Deleted" field (data type:
Boolean). The underlying query criteria is Deleted=0.

I am trying to use the Delete event to set the "Deleted" field value to -1
and requery the form to subsequently hide the revised record. The requery
action fails, however.

Here is the code:

Private Sub Form_Delete(Cancel As Integer)
Cancel = True
Me.Deleted = -1
Me.DateDeleted = Now()
Me.Requery
End Sub

Any guidance will be greatly appreciated.
 
D

Dennis

First, it appears to me that you are not actually DELETING a record. rather,
you are MARKING it as "deleted". So you wouldn't want to fire the
"Form_Delete" event. You'd want to use the "BeforeUpdate" event to set the
value of that column. Additionally, the query that underlies thr form needs
to have, as part of the SQL, " and Deleted = 0" in order to only pull records
whose Deleted column is FALSE. If you do these things, yor ReQuery should be
fine.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top