Results 1 to 13 of 13
  1. #1
    focosi is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    97

    How to undo acCmdPaste ???

    I have a form with a button which executes the "DoCmd.RunCommand acCmdPaste" to paste data from clipboard into textfield. Now, I am trying to add an Undo button, but it seems that "DoCmd.RunCommand acCmdUndo" doesn't work. Neither the Undo button in quick access toolbar works.... What should I use ???

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Do this test. Execute the paste procedure then immediately hit the ESC key. Is the paste undone?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    focosi is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    97
    Yes, it works. Anyway I would prefer a clickable button for the unexperienced user. So, what is the VBA code for the ESC key ? Thanks!

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Some programmers might sentence me to 40 lashes for suggesting but if it's the only thing that works:

    SendKeys "{ESC}", True
    SendKeys "{ESC}", True

    The first ESC should remove the last field entry, the second then cancels all edits in a record.

    I have resorted to this about couple dozen times in my project because I gave up trying to get the UNDO to work.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    focosi is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    97
    still doesn't work... Maybe because the field where the command is applied and has to be undone is unbound ??

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    If it is unbound then there is no table field to be undone. Just set the control to Null.

    When you say 'field' I think table related, say 'control' and I think form related.

    Interesting that actually pressing ESC key clears the entry.

    What happens to this pasted value? You have code to save it to a field? Why isn't it a bound control?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    focosi is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    97
    It's a custom zoombox (as attached), to which I'm trying to add "copy all", "paste all", and "undo paste" buttons. Undoing after pasting doesn't work.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    What is 'zoombox'? What purpose does this serve?

    The posted project doesn't have the paste code.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    focosi is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    97
    A custom zoombox (as explained in the text on the open form in the attached mdb) is a custom replacement for the default Shift+F2 zoombox Microsoft Access has.
    The attached .mdb has no past button on the form : I'm trying to add that using the "DoCmd.RunCommand acCmdPaste" code on the OnClick event.
    What I'm not able to do is a button to undo pasting and return to previous value in the unbound textbox.
    Can you help me ?

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    I still don't understand the purpose of the zoombox. It opens a form that has same info of the textbox on first form. Why?

    Can't analyse code if you don't put it in project. Your narrative indicates the paste works, but not undo. I can't even test paste procedure because code is not provided.

    A solution might be to save the current value of textbox in a variable. If you want to return to this value then set the field to the variable.

    I would set the Click event property to [Event Procedure] then use VBA code to accomplish this process.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  11. #11
    TinaCa is offline Advanced Beginner
    Windows Vista Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    87
    I tried to use the undo command recently, it wasn't working for me either. When the user enters data in a mod-form it is prefilled with data from the original form. But if the user changed their mind, and clicked cancel the system was entering a new record. So, I used a public sub, if they click the cancel button on the mod-form it calls the public sub that either closes the mod-form and or close it and does an undo so none of the data is saved .

    Here is the public sub cod

    If NotSaved = 3 (i.e. they did not click the cancel button) THEN
    DoCmd.OpenForm "frmNameHere"
    Else
    DoCmd.Close acForm, "frmNameHere"
    DoCmd.RunCommand acCmdUndo
    End If

    For some reason if you do the Else part in reverse it doesn't work. Like you had to get focus to the form first than do the undo. I hope this helps.

  12. #12
    focosi is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    97
    Quote Originally Posted by June7 View Post
    I still don't understand the purpose of the zoombox. It opens a form that has same info of the textbox on first form. Why?

    Can't analyse code if you don't put it in project. Your narrative indicates the paste works, but not undo. I can't even test paste procedure because code is not provided.

    A solution might be to save the current value of textbox in a variable. If you want to return to this value then set the field to the variable.

    I would set the Click event property to [Event Procedure] then use VBA code to accomplish this process.
    Dear June7, sorry for the delay. Attached is the modified form as I would like it to appear. As you can see "Paste" button works, while "Undo paste" doesn't. How can I fix it ? Thanks

  13. #13
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    I don't fully understand how the paste action work. When I step debug I see the Teams form box populated with text other than what I typed in the zoombox when I click the Paste button but then when I close the zoom box my typed text is replaced into the Teams form box.

    Somehow in debugging caused the Paste and Undo events to become unavailable. Had to close/reopen the project.

    Don't think I will be much more help. I don't understand need for the 'zoombox'. Seems like unnecessary aggravation. One of the most bizarre and frustrating issues ever ran into.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Undo one action only
    By zoooza84 in forum Access
    Replies: 5
    Last Post: 08-21-2011, 03:04 PM
  2. Replies: 7
    Last Post: 07-15-2011, 08:14 AM
  3. How do I undo the requirement to login every mdb
    By garymkrieg in forum Security
    Replies: 3
    Last Post: 07-11-2011, 03:53 PM
  4. Conditional Formatting through VBA: On Undo
    By Remster in forum Programming
    Replies: 6
    Last Post: 04-13-2011, 09:04 AM
  5. Undo Table Design Changes
    By MelindaP in forum Database Design
    Replies: 6
    Last Post: 07-27-2010, 09:07 AM

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