Have a form that works fine if there is data inputted within the form. The problem I have is that others will be using it and if someone hits the Delete button with no data in any field, then I get a Run-Time error ‘2046’: The command or action ‘DeleteRecord’ isn’t available now window popup with the options to debug or end. I am concerned if they hit debug, they could mess up the scripts. The form ID is a text ID which is created when information is filled in on the form. When debugging, the DoCmd line is highlighted. Basically, I don't want that error to pop up if not data is entered
I have researched to find a solution and have not found a solution.
Private Sub cmdDelete_Click()
If MsgBox("Do you wish to delete this record?", vbYesNo, "Delete Confirmation") = vbYes Then
If MsgBox("Continue, this request will not be processed?" & vbCrLf & _
"This will permanently delete the record.", vbYesNo, "2nd Delete Confirmation") = vbYes Then
DoCmd.RunCommand acCmdDeleteRecord
End If
End If
End Sub