Determining quantity of records deleted with form

D

Dr. Know

How can you determine the number of records deleted by a user from a
form? The default message from Access that states "You are about to
delete 5 records..." implies that this is available - somewhere. If
setmessages off there is NO indication at all...

Can this be retrieved for use in the afterdeleteconfirm event
procedure? If not, where at?

I haven't had any luck with the CurrentDb.RecordsAffected property...
Doesn't seem to work with form deletes, only DAO.

Thanks,
Greg




Dr. Know
 
A

Allen Browne

The Delete event fires for each record in the deletion.

Declare a variable in the form's General Declarations section:
Dim mlngDeleteCount As Long

Increment it in Form_Delete:
mlngDeleteCount = mlngDeleteCount + 1

Reset it in Form_AfterDelConfirm:
mlngDeleteCount = 0

You can read the variable in Form_BeforeDelConfirm, or wherever else you are
trying to give this message.

Note that this only works if:
- you use an mdb, not an adp;
- you have not turned of the confirm events.
 
Top