UNDO button

G

Guest

Hello,

I have set in a form an undo button that runs the accmdUndo command to undo
changes in an edited record. If the button is clicked again before the form
is “dirty†I get an error message about the undo function is not available.
Is there a way to resolve this problem? How may I simulate the esc button
function to the command button;
I mean one click to undo field changes; double click to undo record changes?

Thank you
GL
 
G

Guest

Put this in your Undo button click event.

Private Sub cmdUnDo_Click()
On Error GoTo cmdUnDo_Click_Error

Application.Echo False
With Me
.Undo
If .Recordset.AbsolutePosition > 0 Then
.Recordset.MovePrevious
.Recordset.MoveNext
Else
.Recordset.MoveNext
.Recordset.MovePrevious
End If
End With

cmdUnDo_Click_Exit:

Application.Echo True
On Error Resume Next
Exit Sub

cmdUnDo_Click_Error:

MsgBox "Error " & Err.Number & " (" & Err.Description & _
") in procedure cmdUnDo_Click of VBA Document Form_frmAttributetable"
GoTo cmdUnDo_Click_Exit

End Sub
 
M

Marshall Barton

GL said:
I have set in a form an undo button that runs the accmdUndo command to undo
changes in an edited record. If the button is clicked again before the form
is “dirty” I get an error message about the undo function is not available.
Is there a way to resolve this problem? How may I simulate the esc button
function to the command button;
I mean one click to undo field changes; double click to undo record changes?


Try using the Undo method

Single click:
Screen.PreviousControl.Undo

Double Click:
If Me.Dirty Then Me.Undo
 
G

Guest

Thank you both
They work all but the

Screen.PreviousControl.Undo

method, that does nothing when I click the button
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top