Is this a popup form?
If so, you may like to try deleting from the form's RecorsetClone, as the
menu items will not be available.
Dim rs As DAO.Recordset
With Me!AdminCategoriesSubform.Form
If .NewRecord Then
Beep
Else
Set rs = .RecordsetClone
rs.Bookmark = .Bookmark
If MsgBox("Really delete?", vbOkCancel) = vbOk Then
rs.Delete
end If
End If
End With
Set rs = Nothing
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users -
http://allenbrowne.com/tips.html
Reply to the newsgroup. (Email address has spurious "_SpamTrap")
"Ben" <(E-Mail Removed)> wrote in message
news:behn1i$p07$(E-Mail Removed)...
> Hi guys,
>
> I designed a database and tested it all, and it seemed to work. However,
a
> problem has come to light, which I am one hundred percent positive was not
a
> problem before!
>
> To get to this form, a button is clicked on the main form. It is password
> protected, so when the correct password is entered, up pops the form.
There
> are two buttons available. One to add a category, and one to delete an
> existing category. All the categories are on show in a subform next to
> these buttons.
>
> The problem I am having is selecting a category to delete and pressing the
> delete button. The code for it is shown below. When I click the delete
> button, I get this error: The command or action 'DeleteRecord' isn't
> available now.
>
> Can somebody please help in telling me how I get my code to delete the
> selected record properly?
>
> Thanks very much all,
>
> Ben
>
> ----------------------------
> Private Sub DeleteCategoryAdmin_Click()
> On Error GoTo Err_DeleteCategoryAdmin_Click
> DoCmd.SetWarnings False
> If MsgBox("Are you sure you want to delete this category?", vbQuestion +
> vbYesNo, "Delete Category") = vbYes Then
> Forms!Admin!AdminCategoriesSubform.SetFocus
> DoCmd.RunCommand acCmdSelectRecord
> DoCmd.RunCommand acCmdDeleteRecord
> DoCmd.SetWarnings True
> Forms!Admin!AdminCategoriesSubform.Requery
> End If
>
> Exit_DeleteCategoryAdmin_Click:
> Exit Sub
>
> Err_DeleteCategoryAdmin_Click:
> MsgBox Err.Description
> Resume Exit_DeleteCategoryAdmin_Click
>
> End Sub
> --------------------------------