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