Results 1 to 9 of 9
  1. #1
    data808 is offline Noob
    Windows 8 Access 2007
    Join Date
    Aug 2012
    Posts
    727

    Help with acCmdUndo command

    I have two forms that both run the Docmd.RunCommand acCmdUndo functions. However, they do not work the same. On the first form when the undo code runs it will undo the entire record if the form is dirty. What I mean by this is that if I type in many fields, it will undo everything. This is what I want to happen on the second form.



    The second form when the undo code runs it will only undo one field at a time. This means that if I type in 2 fields, it will only undo the last field I typed in. Does anyone know why this is happening? I am using this undo command right before the user logs out. I want the record to be undone should the user decide to log out without saving.

    Any help is appreciated. Thanks.

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Have you tried using "Docmd.RunCommand acCmdUndo" twice.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    data808 is offline Noob
    Windows 8 Access 2007
    Join Date
    Aug 2012
    Posts
    727
    Yes I have thought of that but I don't feel this will undo the record but just the actions I have done to the record.

    Does anyone know why the undo command is executing differently on the two forms? It's really a mystery that I don't understand. Maybe it's a property setting that is causing the undo command to act differently? It's so weird.

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Yes I have thought of that but I don't feel this will undo the record but just the actions I have done to the record.
    But have you tried it?
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  5. #5
    data808 is offline Noob
    Windows 8 Access 2007
    Join Date
    Aug 2012
    Posts
    727
    I will but its still not very practical because the user may do more actions then the amount of undo commands that I supply the code with. Unless are you suggesting that I use like 20 undo command lines in the code just to be sure it covers all the actions the user may make to the form? And if so, just to verify, will this affect other records if say the user only does make 2 changes to the form before deciding to leave without saving the form which will trigger the 20 undo lines I've added causing it to undo 18 other actions that may have been done to previous records? I am assuming this won't happen and that these undos will only apply to the current record. Correct me if I am wrong and thank you for the help.

  6. #6
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    No. I am only suggesting that you use the command twice, as I said in my original post.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  7. #7
    data808 is offline Noob
    Windows 8 Access 2007
    Join Date
    Aug 2012
    Posts
    727
    Ok so I have something to report. It appears that there is a difference between these commands:

    DoCmd.Runcommand acCmdUndo and Me.Undo

    The runcommand seems to undo one action at a time whereas the Me.Undo will undo the whole form.

    This has been consistent to a certain degree and what I mean by that is, earlier this morning when I got to work, just for the hell of it, I decided to just run it as is with the DoCmd.Runcommand acCmdUndo again to see if I got the same result as I did at the beginning of this post. To my surprise it gave me the result I wanted! It undid the entire record even though I made many changes in creating the new record. I don't know why it happened because I did not change the code at all. So at this point I am confused but I go with it because as long as it's working, I'm not complaining. So I have another form that is similar and would like for this to work the same way so I go ahead and run this form just to see if it will work and it does. I check the code and on this second form it is using the Me.Undo command. So just to experiment I change it to the runcommand version and run it. It stops working. It only undoes one action of the form. But yet this is the exact same code that is working on form 1. I then close the database and reopen it. I try form 1 again just to make sure it's still working and now it has stopped working with the runcommand version of the undo command. So then I change it to the Me.Undo version and then it begins to work. So now I go back to form 2 and change it as well and it too is now working the way I wanted it to.

    So it seems that Me.Undo is what I wanted but for some reason I did get the DoCmd.Runcommand acCmdUndo to work as well but only temporarily. Does anyone know what the hell is up with this? It's totally crazy. I just hope that the Me.Undo doesn't stop working one day because based on my experience here, this seems like a totally possible scenario.

  8. #8
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Quote Originally Posted by data808 View Post
    Ok so I have something to report. It appears that there is a difference between these commands:

    DoCmd.Runcommand acCmdUndo and Me.Undo

    The runcommand seems to undo one action at a time whereas the Me.Undo will undo the whole form.

    This has been consistent to a certain degree and what I mean by that is, earlier this morning when I got to work, just for the hell of it, I decided to just run it as is with the DoCmd.Runcommand acCmdUndo again to see if I got the same result as I did at the beginning of this post. To my surprise it gave me the result I wanted! It undid the entire record even though I made many changes in creating the new record. I don't know why it happened because I did not change the code at all. So at this point I am confused but I go with it because as long as it's working, I'm not complaining. So I have another form that is similar and would like for this to work the same way so I go ahead and run this form just to see if it will work and it does. I check the code and on this second form it is using the Me.Undo command. So just to experiment I change it to the runcommand version and run it. It stops working. It only undoes one action of the form. But yet this is the exact same code that is working on form 1. I then close the database and reopen it. I try form 1 again just to make sure it's still working and now it has stopped working with the runcommand version of the undo command. So then I change it to the Me.Undo version and then it begins to work. So now I go back to form 2 and change it as well and it too is now working the way I wanted it to.

    So it seems that Me.Undo is what I wanted but for some reason I did get the DoCmd.Runcommand acCmdUndo to work as well but only temporarily. Does anyone know what the hell is up with this? It's totally crazy. I just hope that the Me.Undo doesn't stop working one day because based on my experience here, this seems like a totally possible scenario.
    See: http://www.pcreview.co.uk/forums/dif...-t1162440.html
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  9. #9
    data808 is offline Noob
    Windows 8 Access 2007
    Join Date
    Aug 2012
    Posts
    727
    Thanks that was very helpful. Also thanks for all the help and suggestions. Take care.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 09-12-2014, 06:09 AM
  2. Replies: 3
    Last Post: 08-04-2013, 07:11 AM
  3. Little help with search command
    By daniel.ru92 in forum Programming
    Replies: 1
    Last Post: 03-07-2013, 09:44 AM
  4. command buttons
    By nashr1928 in forum Forms
    Replies: 23
    Last Post: 10-15-2010, 04:09 PM
  5. Replies: 1
    Last Post: 07-27-2010, 02:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums