Page 2 of 2 FirstFirst 12
Results 16 to 23 of 23
  1. #16
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772

    Does this help http://www.ehow.com/how_6080836_conv...ual-basic.html
    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.

  2. #17
    edson is offline Advanced Beginner
    Windows 8 Access 2007
    Join Date
    Oct 2014
    Posts
    57
    Hello June7. How are you? Yes, it helped in deed. I was about to write you a note mentioning that. For some reason the vba code behind this access built-in macro works fine. The code we wrote at that time is about the same but does not work. Any way, I used that one and had my problem solved. So I understand now you also have a vba code to delete table records from a button click event, correct?
    Cheers

  3. #18
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Don't really follow that question. You want to know if I have 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.

  4. #19
    edson is offline Advanced Beginner
    Windows 8 Access 2007
    Join Date
    Oct 2014
    Posts
    57
    No, this is not a question... You said in your last note:

    "I am in U.S. I am interested in the UNDO solution. I have never been able to get this to work in VBA and I never use macros, hence resorting to SendKeys. Glad you have a solution."

    That is why I wrote this note to you: By converting the built in macro to vba you'll have, as I do now, the UNDO solution in code.

  5. #20
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    I don't use macros so never considered first building a macro and converting. And I lost track of this thread and forgot. I will have to try that. Thank you for reminder.
    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.

  6. #21
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    An update.

    I seem to remember trying without success Me.Undo and DoCmd.RunCommand acCmdUndo but that was several years ago.

    The macro converter generated VBA:

    Code:
    Private Sub Command321_Click()
    On Error GoTo Command321_Click_Err
        On Error Resume Next
        DoCmd.RunCommand acCmdUndo
        If (MacroError <> 0) Then
            Beep
            MsgBox MacroError.Description, vbOKOnly, ""
        End If
    Command321_Click_Exit:
        Exit Sub
    Command321_Click_Err:
        MsgBox Error$
        Resume Command321_Click_Exit
    End Sub
    Initial testing shows this works. I also tested without the Resume and error handler code and still works. I wonder why did not work when first tried years ago. Now I will have to try again in my 'big' db. However, not sure how to use with a couple of complex form/subforms arrangements I have, where even SendKeys would not help. Once user moves focus to another form, all edits are committed and cannot be canceled. Suppose each subform can have an Undo button and the main form can have one that will be disabled when any subform gets focus.

    Ooops, have to first check if form is Dirty.

    If Me.Dirty Then DoCmd.RunCommand acCmdUndo
    Last edited by June7; 11-25-2014 at 06:40 PM.
    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. #22
    edson is offline Advanced Beginner
    Windows 8 Access 2007
    Join Date
    Oct 2014
    Posts
    57
    Hello June7. Yeah! It sounds like a good idea. Let me confess one thing to you: As a novice I still do not know all the Access commands and resources, so sometimes I make Access work for me (eh,eh,eh...). For instance: Some time ago I did not know how to code a huge SQL instruction... so what I did? I built a fake query to obtain the results I wanted and then went to its SQL mode to see related SQL code. It was just a matter to copy it and paste it and make few changes to have it working in my VBA. Maybe the sênior programmers would not endorse such behavior, however I get to have my problems some how solved at the end of the day. On the other hand I spend effort to study and understand the new commands I use/learn. I cannot complain after all since I have initiated using Access in the last 6 mo. or so.
    Later gator (in the next thread). Cheers.

  8. #23
    edson is offline Advanced Beginner
    Windows 8 Access 2007
    Join Date
    Oct 2014
    Posts
    57
    WOWWW ! I don't think I deserve to be promoted to Advanced Beginner. I just saw it now and would like to thank you for that. Have a blessed day.
    Edson

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 6
    Last Post: 10-07-2014, 03:02 PM
  2. Replies: 2
    Last Post: 03-26-2014, 07:30 AM
  3. Replies: 2
    Last Post: 01-02-2014, 03:05 PM
  4. Deleting records on a form using VBA
    By lawdy in forum Programming
    Replies: 5
    Last Post: 05-06-2013, 06:06 PM
  5. Replies: 11
    Last Post: 12-14-2010, 01:25 PM

Tags for this Thread

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