I have a form on which I added a button to delete a record by running a delete query. Instead of the pre-defined message boxes (you are about to run a query... and you are about to delete 1 record...) I would like to supress those messages and show a message only if deleting the record violates referential integrity (You cannot delete this record until related records are removed.)
My code is as follows - notice I have set warnings false, then after the docmd.openquery statement I set them to true again.
Private Sub cmdDelete_Click()
On Error GoTo Err_cmdDelete_Click
Dim stDocName As String
Dim strMessage As String
stDocName = "qryDeleteRecord"
DoCmd.SetWarnings False
DoCmd.OpenQuery stDocName, acNormal, acEdit
DoCmd.SetWarnings True
Exit_cmdDelete_Click:
Exit Sub
Err_cmdDelete_Click:
Resume Exit_cmdDelete_Click
End Sub
Does anyone know how to generate a different message such as above?
Thanks for your help!
Judy
My code is as follows - notice I have set warnings false, then after the docmd.openquery statement I set them to true again.
Private Sub cmdDelete_Click()
On Error GoTo Err_cmdDelete_Click
Dim stDocName As String
Dim strMessage As String
stDocName = "qryDeleteRecord"
DoCmd.SetWarnings False
DoCmd.OpenQuery stDocName, acNormal, acEdit
DoCmd.SetWarnings True
Exit_cmdDelete_Click:
Exit Sub
Err_cmdDelete_Click:
Resume Exit_cmdDelete_Click
End Sub
Does anyone know how to generate a different message such as above?
Thanks for your help!
Judy