Nothing happens when running DoCmd.RunCommand acCmdDeleteRecord (1 Viewer)

home70

Registered User.
Local time
Today, 08:35
Joined
Jul 10, 2006
Messages
72
I am trying to get a button to delete the current record using the command:

DoCmd.RunCommand acCmdDeleteRecord

but nothing happens when it runs. I am sure the code is running because I have set a msgbox to come up after it in the click event and it comes up.

If I use the button wizard to create the button it will delete a record, but that seems to break the "lost focus" code I use for the button.

Thank you.

(Access 2010)
 

RuralGuy

AWF VIP
Local time
Today, 07:35
Joined
Jul 2, 2005
Messages
13,826
Do you have "warnings" turned off? Turn them on and see if it is throwing an error.
 

home70

Registered User.
Local time
Today, 08:35
Joined
Jul 10, 2006
Messages
72
Thanks for the help Rural Guy.

I put this into the click event ahead of the delete command:

DoCmd.SetWarnings True

but it did the same thing.

Is there another (better?) way to make sure warnings are on?
 
Last edited:

boblarson

Smeghead
Local time
Today, 06:35
Joined
Jan 12, 2001
Messages
32,059
Sometimes the button and the code get separated from each other. Did you happen to create the button, write the code and then rename the button? If you did that the code is still on the old control name's click event and it needs to be moved to the click event of the new name.

Also, make sure that [Event Procedure] is shown in the click event property of the properties dialog. Sometimes that can get disconnected too if you copy a control for example.
 

home70

Registered User.
Local time
Today, 08:35
Joined
Jul 10, 2006
Messages
72
Thanks guys. Bob, after checking for the things you mentioned and finding that it all seemed correct, I just rebuilt the form. It seemed less frustrating even if it was a pain. I'm glad it was a simple form.

Thanks again guys.
 

RuralGuy

AWF VIP
Local time
Today, 07:35
Joined
Jul 2, 2005
Messages
13,826
Glad to hear you got it sorted. Thanks for posting back with your solution and success.
 

Users who are viewing this thread

Top Bottom