error trying to delete a rec

jojo

Registered User.
Local time
Today, 18:18
Joined
Jul 20, 2012
Messages
51
In Access 2010, have a form with a comand button that goes thru a range of recs and checks a field to see if that rec should be deleted. I had an identical button in an old system I wrote using Access 2002, so I copied the code but it just keeps going past the end of the records and adds new blak recs to the table! I tried using a macro which gave this command to delete a record:
docmd.RunCommand acCmdDeleteRecord
but when i converted it to code, i got this error: runtime error 2046 the action delete record isnt availabe now. I did not type the line of code, it was generated. Access is not even user-friendly to itself! Any ideas?
Thank you very much. And thank yuo to all the responders of this great forum, who give their time just for the pleasure of helping others!
Jojo
 
The Runtime Error is the result you find when VBE is open, you're in edit/design mode when you attempt an action and also when the command is not pointed at a record which it can delete. I can easily reproduce that error by typing it in the immediate window of the VBE.

That being said, we'll need a little more of the surrounding code to determine what to do to help.

Cheers,
Goh
 
Last edited:
thank you GohDiamond for your reply. All i need is a line of code that says
If 'a condition is met Then
delete this rec
endif
How does one say "delete a rec" without a delete command button?
thank you in advance!!
Jojo
 

Users who are viewing this thread

Back
Top Bottom