[AccessD] Determining the records about to be deleted by the DBEngine

Gustav Brock gustav at cactus.dk
Wed Sep 20 01:18:35 CDT 2017


Hi Bill

Thanks for the closing remarks and code.

I once wrote similar code, though - as I recall - without using any mouse event. 
However, I couldn't locate it, and as I haven't had a need for years for handling this task, I couldn't add anything. Thus, I didn't comment your original posting.

/gustav

-----Oprindelig meddelelse-----
Fra: AccessD [mailto:accessd-bounces at databaseadvisors.com] På vegne af Bill Benson
Sendt: 19. september 2017 20:10
Til: Access Developers discussion and problem solving <accessd at databaseadvisors.com>
Emne: Re: [AccessD] Determining the records about to be deleted by the DBEngine

And now this is solved... I should keep an array of IDs determined in the Delete event, then test that array and all dependencies in other tables in the BeforeDelConfirm event.

On Mon, Sep 18, 2017 at 6:16 PM, Bill Benson <bensonforums at gmail.com> wrote:

> How, in the BeforeDelConfirm event, can I determine what records are 
> about to be deleted so that I can give the user more info than 
> Access's "how many records will be deleted" message? For example, 
> related records in other tables that I have to maintain the cascading 
> deletions for (the data integrity is not set, so I have to take care of the cleanup in code)?
>
> When I put code to test recordsetclone, form.Selheight, Form.Seltop 
> kind of stuff in MouseMove of the datasheet form - I get a different 
> set of records by the time Access condenses the data set (I think it 
> ut retriggers MouseMove on its own, when pushing the user onto the 
> next available record that would exist post-delete, while showing the 
> transactional view. If the user cancels, this problem goes away but if 
> the user does not cancel, I do not want Access reporting on the record 
> below where the user is deleting from, the way it seems to now.
>
> I would be surprised there is nothing I can use like Access natively 
> uses to identify which records are about to be deleted?
>
>
> Form Class Module
> Dim arSelectedItems() as long
> Dim StrID as String
>
> Private Sub Form_BeforeDelConfirm(Cancel As Integer, Response As 
> Integer) Dim i As Long For i = 1 To UBound(arSelectedItems)
>     strID = strID & "," & arSelectedItems(i)
>
> Next
>
>     Debug.Print Debug.Print Mid(strID, 2)
>
> End Sub
>
>
> Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As 
> Single, Y As Single) Dim rst As Recordset Dim F As Form Dim strID As 
> String Set F = Me Dim i As Long ReDim arSelectedItems(0 To 
> F.SelHeight) If Me.SelHeight = 0 Then
>     Exit Sub
> End If
> Set rst = Me.RecordsetClone
> rst.MoveFirst
> For i = 1 To F.SelTop - 1
>     rst.MoveNext
> Next
> For i = 1 To F.SelHeight
>     arSelectedItems(i) = rst!ID
>     strID = strID & "," & arSelectedItems(i)
>     rst.MoveNext
> Next
> Debug.Print Mid(strID, 2)
> End Sub 



More information about the AccessD mailing list