Form Delete Question

P

Posse John

I have a form that shows log entries for things that occur. This form is
based on a query that shows all records that don't have the field
'EntryDeleted' as true.

I need to retain deleted entries for documentation (not many deletions occur).

In the Form_Delete event, I have code to change field 'EntryDeleted' to true
if it is deleted, and I cancel the Delete event.

Problem...how do I update the form that is showing the records, to remove
the one that was just marked deleted?

I tried putting a refresh within the Form_Delete event, but it errors out.
I get:
RUN TIME ERROR '3246'
Operation not supported in transactions.
 
A

Allen Browne

Access deletes the record in a transaction, and if you cancel the deletion
it restores the record. That's why you cannot requery the form in its Delete
event.

Once the deletion is complete, Access fires the AfterDelConfirm event. I
haven't tried, but you may be able to perform the Requery in this event. You
would need to do this only if the deletion was not cancelled, so the code
would be:

If Status = acDeleteOk Then
Me.Requery
End If

Notes:
1. AfterDelConfirm fires only if you have confirmations turned on.

2. The timing of AfterDelConfirm is different in an ADP than in an MDB.

3. The Requery will take you back to the first record (as if you just loaded
the form.)

4. A bug in Access 2002 Service Pack 3 generates a spurious "No Current
Record" error in the AfterDelConfirm event.
 

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