B
Ben
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
--------------------------------
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
--------------------------------