Simple Yes/No Message Box (1 Viewer)

Mist

Registered User.
Local time
Today, 14:41
Joined
Mar 5, 2012
Messages
66
I have a 'delete' (maco) button on a form to delete the current record and then do the same in other tables. It works just fine but I want to add a warning message to it with the option to cancel deletion. Will appreciate some guidance here :confused: Thanks
 

vbaInet

AWF VIP
Local time
Today, 12:41
Joined
Jan 22, 2010
Messages
26,374
You need to interrupt the delete action in the Before Delete Confirm and Delete events of the Form. I'm guessing the form is bound.

Your code could look like this:
Code:
Private Sub Form_BeforeDelConfirm(Cancel As Integer, Response As Integer)
    Response = acDataErrContinue
End Sub
 
Private Sub Form_Delete(Cancel As Integer)
    If MsgBox("Do you want to delete?", vbYesNo + vbExclamation, "Delete confirmation!") = vbNo Then
        Cancel = True
    End If
End Sub
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 07:41
Joined
Feb 19, 2002
Messages
43,302
why do you have to delete the record from more than one table?
 

Mist

Registered User.
Local time
Today, 14:41
Joined
Mar 5, 2012
Messages
66
It's a 'control' record from a table which accumulates related information from various other tables sharing a common reference number and each having a one-to-one relationship. Viewed together this 'accumulated' information describes the entity referred to by the reference number.

I can't put all the fields in one table as it would exceed the 255 field limitation by at least double.

Hence, when (if) I delete the control record I remove the related record from each of the data tables as well.
 

vbaInet

AWF VIP
Local time
Today, 12:41
Joined
Jan 22, 2010
Messages
26,374
I'm sensing that your tables may not be properly normalised. Have you thought about using Cascade Delete?
 

Users who are viewing this thread

Top Bottom