?
Solved

DoCmd.RunCommand acCmdUndo

Posted on 2003-02-28
13
Medium Priority
?
1,669 Views
Last Modified: 2008-02-26
Hey everyone,

I am using DoCmd.RunCommand acCmdUndo to undo changes in my form if the user hits the cancel button.  It works great for the main form but it does not work for the subform.  How do I undo changes in both the main form and subform on the cancel button?????

Any Ideas,
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
  • 5
  • 3
  • 3
  • +1
13 Comments
 
LVL 6

Expert Comment

by:PsychoDazey
ID: 8041675
Heres an article you may find useful:
http://support.microsoft.com/default.aspx?scid=kb;en-us;208833
Basically you have to create some type of delete query that deletes the corresponding data in the subform table after the docmd.runcommand line
You may want to set a variable using the main form key field, run the undo action and then run a SQL statement like:
docmd.runsql "DELETE * FROM SubformTable WHERE table.field = " & YourVariable & ";"
0
 
LVL 2

Expert Comment

by:kraig
ID: 8041731
Whenever I have a situation like this I find it easiest to have the form's data source be a temporary table.  On cancel, do nothing.  On submit, write the data in the temporary table to the primary table.

Just make sure the temp table is cleared when the form opens.
0
 

Author Comment

by:itwebguy
ID: 8041752
Yeah,

I wanted to do the temp table thing but my supervisor wanted to just use the undo command.

Itwg - hands tied
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!

 
LVL 2

Expert Comment

by:kraig
ID: 8041790
I don't think there is an easy solution for un-doing changes to a sub-form.

Instead of a temp table, make the form un-bound and populate the fields when the form opens.

Then on cancel do nothing, and on submit commit the changes.  I've found these types of forms are faster loading on the user end especially when the form is based on a large recordset.

Tell your supervisor that you can use undo and have it not work, or use another method and have it work.
0
 
LVL 6

Expert Comment

by:PsychoDazey
ID: 8041804
If you used the temp table thing how would you deal with multiple records in your subform?  Would you have to run the append query after each time you added a new record to the subform?
0
 
LVL 2

Expert Comment

by:kraig
ID: 8041834
Two temp tables.
Just run the query(s) when the form is closed.
0
 
LVL 6

Expert Comment

by:PsychoDazey
ID: 8041893
You can get the undo to work with the article I linked, its just not as straight-forward as you would think.  Thanks Microsoft!
0
 

Author Comment

by:itwebguy
ID: 8042422
Yeah... I have about five different subforms ...

Does anyone know how to call the undo typing command using VBCode??  I know that works but can I write that function in code or call it?

Itwg
0
 
LVL 6

Expert Comment

by:PsychoDazey
ID: 8042631
If you mean you want to undo what you typed into a control use: me.ControlName.Undo (or Formname.ControlName.undo depending on where you call it from.)
0
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 8042634
Issue 2 undo commands - one for the subform's (or each subform's) Form object and one for the main form.
0
 

Author Comment

by:itwebguy
ID: 8042652
what does the undo command look like for a subform??
Itwg!!
0
 
LVL 41

Accepted Solution

by:
shanesuebsahakarn earned 90 total points
ID: 8042709
If you are calling it from the main form, you can do:
Me!MySubformControl.Form.Undo

Make sure MySubformControl is the name of the subform control, not of the subform itself.
0
 
LVL 6

Expert Comment

by:PsychoDazey
ID: 8042814
So you'll have to undo each control individually it looks like.
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Suggested Courses

764 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