Replace standard delete message

K

Kurt

I'd like to replace the standard delete message
("Relationships that specify cascading deletes are about
to cause X records . . . to be deleted.") with my own
message.

How can I edit the code for my Delete button to do this?

Thanks. Kurt

-----------------------------------------
Private Sub cmdDelete_Click()
On Error GoTo Err_cmdDelete_Click

DoCmd.DoMenuItem acFormBar, acEditMenu, 8, ,
acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, ,
acMenuVer70

Exit_cmdDelete_Click:
Exit Sub
Err_cmdDelete_Click:
MsgBox Err.Number & Err.Description
Resume Exit_cmdDelete_Click
End Sub
-----------------------------------------
 
B

Bill Taylor

you can use the on delete event to setwarnings(0) to suppress the message
and then put your own msgbox instead. then be sure to turn the
setwarnings(-1) on in another event like on current.
 
K

Kurt

you can use the on delete event to setwarnings(0)
to suppress the message and then put your own msgbox
instead. then be sure to turn the setwarnings(-1) on
in another event like on current.

Thanks. I found an alternative approach
(http://www.mvps.org/access/forms/frm0021.htm) which
calls a function, works quite well, and provides some
additional control. Code below for those interested.
- Kurt

''''''''''''''''''''''''''''''''''''''
Private Sub cmdDelete_Click()
If Not (fDelCurrentRec(Me)) Then
On Error GoTo Err_NotTrue
End If

Me.cboRspnsID.Requery

Exit_cmdDelete_Click:
Exit Sub
Err_NotTrue:
If Err.Number = 3218 Then
Resume Exit_cmdDelete_Click
ElseIf Err.Number = 2501 Then ' User said no,
suppress error
Resume Exit_cmdDelete_Click
Else
MsgBox Err.Number & Err.Description
Resume Exit_cmdDelete_Click
End If

End Sub

''''''''''''''''''''''''''''''''''''''

Function fDelCurrentRec(ByRef frmSurveyResponses As Form)
As Boolean
On Error GoTo Err_Section

Dim iresponse As Integer
iresponse = MsgBox("Are you sure you want to delete the
entire record?" & _
Chr(13) & Chr(13) & "Continue?", 4 + 32 + 256)
If iresponse = 7 Then
Exit Function
Else
End If

With frmSurveyResponses
If .NewRecord Then
.Undo
fDelCurrentRec = True
GoTo Exit_Section
End If
End With

With frmSurveyResponses.RecordsetClone
.Bookmark = frmSurveyResponses.Bookmark
.Delete
frmSurveyResponses.Requery
End With
fDelCurrentRec = True
Exit_Section:
Exit Function

Err_Section:
fDelCurrentRec = False
Resume Exit_Section
End Function

'''''''''''''''''''''''''''''''''''''''
 

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