• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2179
  • Last Modified:

DoCmd.RunCommand acCmdUndo Error

I am getting an error when I use DoCmd.RunCommand acCmdUndo  - the error is "run-time error '2046':The command or action 'Undo' isn't available now."

Any Ideas???????

I need a good answer fast.

ITWG
0
itwebguy
Asked:
itwebguy
1 Solution
 
__Holly__Commented:
docmd.runmenuitem is what you need to do.

you should just try using the CommandButtonWizard in order to make a default Undo button, and then pull the full string out of it.


    DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70

0
 
shanesuebsahakarnCommented:
Where are you attempting to call the code from, and what is it trying to undo ?

If it is a form, issue the Undo command directly for the form:
Forms!MyForm.Undo
0
 
itwebguyAuthor Commented:
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70

I did that and I still got the error!!!

ITWG - very frustrated
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
shanesuebsahakarnCommented:
DoMenuItem is analogous to RunCommand. It is only provided for backwards compatibility, and you should avoid using it.
0
 
itwebguyAuthor Commented:
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70

I did that and I still got the error!!!

ITWG - very frustrated
0
 
shanesuebsahakarnCommented:
Have you tried my suggestion ?
0
 
itwebguyAuthor Commented:
Yeah... I got your suggestion to work on the main form but can't get it to work on the subform.  I am calling a procedure from the main form to do an undo in the sub form but keep getting an error.

0
 
itwebguyAuthor Commented:
How do you reference a subform from within itself??
0
 
shanesuebsahakarnCommented:
To reference the subform, use:
Forms!MyForm!MySubformControl.Form.Undo

Ensure that MySubformControl is the name of the subform control - click on the main form in design view and check the Name property in the properties window. This is the name you need to put in.
0
 
itwebguyAuthor Commented:
tried that already and it still does not work.
0
 
shanesuebsahakarnCommented:
What error does it give you ?
0
 
thegornieCommented:
You're getting the error because the Undo command isn't available at that instant.  I have two different possible solutions, try them both separately and see which works better for you:


1) Use the Esc key Undo functionality.  Pressing the Esc key should be the same as clicking Edit/Undo thru the menu system, except you don't get a nasty error message if Undo is unavailable.  Instead of the DoCmd statement, run this instead:

Sendkeys "{ESC}"


2) Bypass error trapping.  Before the DoCmd line, insert the following:

On Error Resume Next

Then after the line that creates the error, make sure you reset the error trapping to what you had before (On Error Goto Err_SubName_Click or whatever).



The second method works perfectly when you're sure that the error is not critical.

Good luck,
theGornie
0
 
nexusnationCommented:
Hi itwebguy,
This question has been abandoned and needs to be finalized (108 days since last comment).

   You can accept an answer, split the points, or get a refund. Go to
   http://www.cityofangels.com/Experts/Closing.htm for information and options.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

nexusnation
EE Cleanup Volunteer for Microsoft Access
0
 
1WilliamCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Accept question, points to shanesuebsahakarn
Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

1William
EE Cleanup Volunteer
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now