PC Review


Reply
Thread Tools Rate Thread

DeleteRecord error on an open form

 
 
Ben
Guest
Posts: n/a
 
      9th Jul 2003
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
--------------------------------


 
Reply With Quote
 
 
 
 
Allen Browne
Guest
Posts: n/a
 
      10th Jul 2003
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
> --------------------------------



 
Reply With Quote
 
 
 
 
Ben
Guest
Posts: n/a
 
      10th Jul 2003
Thanks so much Allen. That worked a treat!

Ben

"Allen Browne" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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
> > --------------------------------

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DeleteRecord =?Utf-8?B?Z2xuYm56?= Microsoft Access Form Coding 1 14th Oct 2006 01:51 PM
Still getting error 2501 on DeleteRecord =?Utf-8?B?QmFieSBGYWNlIExlZQ==?= Microsoft Access Form Coding 2 23rd Mar 2006 05:20 PM
The Command or Action 'DeleteRecord' isn't available now EE Microsoft Access Forms 0 8th Aug 2004 01:03 AM
DeleteRecord error on an open form Ben Microsoft Access Forms 3 10th Jul 2003 07:43 PM
DeleteRecord error on an open form Ben Microsoft Access 2 10th Jul 2003 07:43 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:48 AM.