Deleteing Multiple records from a sub form in datasheet view

B

BigHughie

I'll confess that I havent exactly tried everything I know on this issue yet,
but deadlines mean I could do with some help quickly.

I have written a large applicatoion in Access Xp (circa 150 tables , 200
forms etc) and all is going very well. I am a very experienced Access
developer and i only have 4 unresolved issues. This is number 3

I have a main and sub form, and want to be able to allow the user to delete
either all or just the Highlighted records shown in the sub datasheet by
pressing the delete key. Before deleting I want to ask the user if they want
to delete the records, and if yes then remove the related records from the
subform.

What I dont want is for Access to ask the question repeatedly for every
record selected. If I put the confirmation question in the on delete event,
that is what happens.

I confess never being able to remember when to use before / after del
confirm / on_delete, and thought that I'd dealt with this ages ago. But
apparently not. Any help would be much appreciated
 
A

Allen Browne

The Delete event fires for each record, so this is the event you do NOT
want.

The BeforeDelConfirm event fires once for the deletion. It is very easy to
use this event, with a custom message or with the standard Access message
(which has the advantge of mentioning any cascades). If you use your own
MsgBox() set the Response argument so Access knows to suppress its own.

At startup, you may wish to ensure the confirmations are on, e.g.:
If Not Application.GetOption("Confirm Record Changes") Then
Application.SetOption ("Confirm Record Changes"), True
End If

If you are using an ADP instead of an MDB/MDE, check out:
ACC2000: Order of Form Delete Events Differs in ADPs and MDBs
at:
http://support.microsoft.com/default.aspx?scid=kb;en-us;234866
 

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