Hello,
I am using this code on my delete buttons (throughout the DB):
It works fine if the database window is shown, but if I open the database normally (without pressing shift on startup - so no db window is shown, and standard tooldbars are disabled) it doesn't work, coming up with:
Runtime error 2046:
The command or action 'DeleteRecord' isn't available now.
Deletions are allowed in the properties box, so there is no reason I can see why it doesn't work.
Help!?!
I am using this code on my delete buttons (throughout the DB):
Code:
Private Sub cmdDelete_Click()
DoCmd.SetWarnings False
If MsgBox("This equipment record will be irreversibly deleted. Are you sure you wish to continue?", vbCritical + vbYesNo, "Delete Equipment Record") = vbYes Then
DoCmd.RunCommand acCmdDeleteRecord
End If
cmdDelete_Click_Exit:
DoCmd.SetWarnings True
Exit Sub
cmdDelete_Click_Err:
If Err = 2046 Then 'The command or action 'Delete Record' isn't available now
Exit Sub
ElseIf Err = 2501 Then 'The Delete Record action was canceled
Exit Sub
Else
MsgBox Err.Number & " - " & Err.Description
Resume cmdDelete_Click_Exit
End If
End Sub
It works fine if the database window is shown, but if I open the database normally (without pressing shift on startup - so no db window is shown, and standard tooldbars are disabled) it doesn't work, coming up with:
Runtime error 2046:
The command or action 'DeleteRecord' isn't available now.
Deletions are allowed in the properties box, so there is no reason I can see why it doesn't work.
Help!?!