Passing the form reference to an undo function

chrisbrookeanna

Registered User.
Local time
Today, 00:35
Joined
Apr 6, 2004
Messages
14
Hi Ive got this code:-

Function Old_values(Object As Form)

Dim ctlTextbox As Control
For Each ctlTextbox In Object.Controls
If ctlTextbox.ControlType = acTextBox Then
ctlTextbox.Value = ctlTextbox.OldValue
End If
Next ctlTextbox
End Function


I want to pass into it different forms but I keep getting type mismatch errors, im calling it by:-

Old_values ("Functional Data Set") - what should this be?
 
Thanks Rich

Rich said:
Why not just use Me.Undo ?

Me.Undo wont work for some reason, do you know how to correct my original coding?
 
Me.Undo

Rich said:
Where and when have you tried using Me.Undo?

Hi Rich,

When I change data it loads another form to sanction the change with a change number, you can either hit ok or cancel on this new form. Upon hitting cancel I tried Forms![Name of form].undo

I cant use me, because im not currently on the form to change back to original data.
 
G’day chrisbrookeanna

One method would be something like this…

On Form frmMain: -

Code:
Option Explicit
Option Compare Text

Public blnCancelUpdate As Boolean


Private Sub Form_BeforeUpdate(ByRef intCancel As Integer)

    DoCmd.OpenForm "frmSanctionChange", , , , , acDialog, Me.Name
    
    If (blnCancelUpdate = True) Then
        Me.Undo
        intCancel = True
        blnCancelUpdate = False
    End If

End Sub
And on Form frmSanctionChange: -

Code:
Option Explicit
Option Compare Text


Private Sub cmdCancel_Click()

    If Nz(Me.OpenArgs, "") <> "" Then
        Forms(Me.OpenArgs).blnCancelUpdate = True
        DoCmd.Close acForm, Me.Name
    End If

End Sub
Hope that helps.

Regards,
Chris.
 

Users who are viewing this thread

Back
Top Bottom