Correction using undo function (1 Viewer)

spleewars

Registered User.
Local time
Today, 13:32
Joined
Jan 28, 2011
Messages
28
on event of a yes/no button

if me.object 1 then
unitsection = 0#
else
if me.object 1 then
unitsection.undo
end if
end if
end sub

the undo function is not working... any better idea?
 

Beetle

Duly Registered Boozer
Local time
Today, 14:32
Joined
Apr 30, 2011
Messages
1,808
Your code makes no sense.

if me.object 1 then

What is me.object? Is the button, or some other field/control, named object? If so it shouldn't be as Object is a Access / VBA reserved word. If it's a Yes/No field it will either be True (-1), False (0) or possibly Null, not 1. Plus, you're using the same argument in two different If statements, one inside the other, so the second If statement will never be processed.

Can you clarify what it is you're trying to do here?
 

ghudson

Registered User.
Local time
Today, 16:32
Joined
Jun 8, 2002
Messages
6,195
This should give you an idea on how to use an Undo function...

Code:
    If MsgBox("Do you want to Undo the unsaved changes you have made to the current record?", vbQuestion + vbYesNo, "Undo Changes") = vbYes Then
        If Me.Dirty Then
            DoCmd.RunCommand acCmdUndo
        Else
            MsgBox "There were no modifications made to the current record.", vbInformation, "Invalid Undo"
        End If
    Else
        MsgBox "User aborted the Undo function.", vbCritical, "Aborted Undo"
    End If
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 16:32
Joined
Feb 19, 2002
Messages
43,477
DoCmd.RunCommand acCmdUndo
and
Me.Undo
both undo ALL pending changes for the current form.

Me.ControlName.Undo
only backs out the change to the named control.
 

Users who are viewing this thread

Top Bottom