itwebguy
asked on
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
Any Ideas???????
I need a good answer fast.
ITWG
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
I did that and I still got the error!!!
ITWG - very frustrated
I did that and I still got the error!!!
ITWG - very frustrated
DoMenuItem is analogous to RunCommand. It is only provided for backwards compatibility, and you should avoid using it.
ASKER
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
I did that and I still got the error!!!
ITWG - very frustrated
I did that and I still got the error!!!
ITWG - very frustrated
Have you tried my suggestion ?
ASKER
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.
ASKER
How do you reference a subform from within itself??
To reference the subform, use:
Forms!MyForm!MySubformCont rol.Form.U ndo
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.
Forms!MyForm!MySubformCont
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.
ASKER
tried that already and it still does not work.
What error does it give you ?
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
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
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
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
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
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
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