?
Solved

DoCmd.RunCommand acCmdUndo Error

Posted on 2003-03-05
15
Medium Priority
?
1,997 Views
Last Modified: 2007-12-19
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
Comment
Question by:itwebguy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
15 Comments
 
LVL 1

Expert Comment

by:__Holly__
ID: 8073983
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
 
LVL 41

Accepted Solution

by:
shanesuebsahakarn earned 225 total points
ID: 8074016
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
 

Author Comment

by:itwebguy
ID: 8074065
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70

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

ITWG - very frustrated
0
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 8074155
DoMenuItem is analogous to RunCommand. It is only provided for backwards compatibility, and you should avoid using it.
0
 

Author Comment

by:itwebguy
ID: 8074182
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70

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

ITWG - very frustrated
0
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 8074198
Have you tried my suggestion ?
0
 

Author Comment

by:itwebguy
ID: 8074227
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
 

Author Comment

by:itwebguy
ID: 8074276
How do you reference a subform from within itself??
0
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 8074403
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
 

Author Comment

by:itwebguy
ID: 8074430
tried that already and it still does not work.
0
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 8074476
What error does it give you ?
0
 

Expert Comment

by:thegornie
ID: 8091731
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
 
LVL 12

Expert Comment

by:nexusnation
ID: 8785197
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
 
LVL 18

Expert Comment

by:1William
ID: 8879626
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

Independent Software Vendors: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question