T
tina
SetWarnings is already turned off when the record is deleted, so my guess is
that the system is showing that message because of the subsequent (and
unnecessary) line
Resume Exit_btnDeleteRecord_Click
try this:
Private Sub btnDeleteRecord_Click()
On Error GoTo Err_btnDeleteRecord_Click
DoCmd.Beep
If vbYes = MsgBox("Are you sure you want to delete the product?",
vbCritical + vbYesNo, "Product Deletion") Then
DoCmd.SetWarnings False
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
Else
MsgBox "The product is still in the list", , "Delete action
canceled"
End If
Exit_btnDeleteRecord_Click:
DoCmd.SetWarnings True
Exit Sub
Err_btnDeleteRecord_Click:
MsgBox Err.Number & " " & Err.Description
Resume Exit_btnDeleteRecord_Click
End Sub
if you're using an error handler in a procedure that turns off Warnings,
it's a good idea to make sure the handler turns *on* Warnings before exiting
the procedure. also, if an unanticipated error triggers the handler, it
helps to see the error number, as well as the description, for trapping
purposes.
btw, in A2000 or newer, you can replace the two DoMenuItem lines with a
single line
DoCmd.RunCommand acCmdDeleteRecord
it may work in A97 as well, but i'm afraid that i can't remember.
hth
that the system is showing that message because of the subsequent (and
unnecessary) line
Resume Exit_btnDeleteRecord_Click
try this:
Private Sub btnDeleteRecord_Click()
On Error GoTo Err_btnDeleteRecord_Click
DoCmd.Beep
If vbYes = MsgBox("Are you sure you want to delete the product?",
vbCritical + vbYesNo, "Product Deletion") Then
DoCmd.SetWarnings False
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
Else
MsgBox "The product is still in the list", , "Delete action
canceled"
End If
Exit_btnDeleteRecord_Click:
DoCmd.SetWarnings True
Exit Sub
Err_btnDeleteRecord_Click:
MsgBox Err.Number & " " & Err.Description
Resume Exit_btnDeleteRecord_Click
End Sub
if you're using an error handler in a procedure that turns off Warnings,
it's a good idea to make sure the handler turns *on* Warnings before exiting
the procedure. also, if an unanticipated error triggers the handler, it
helps to see the error number, as well as the description, for trapping
purposes.
btw, in A2000 or newer, you can replace the two DoMenuItem lines with a
single line
DoCmd.RunCommand acCmdDeleteRecord
it may work in A97 as well, but i'm afraid that i can't remember.
hth