undo

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a command button on a main form that I want to undo what was typed in
this is the code I found
If Me.Dirty Then
Me.Undo
Else
Beep
End If
End Sub

does it make a difference if what I want undone is on a subform?

Chey
 
Chey said:
I have a command button on a main form that I want to undo what was typed in
this is the code I found
If Me.Dirty Then
Me.Undo
Else
Beep
End If
End Sub

does it make a difference if what I want undone is on a subform?

Chey

How many Controls have you on the form? A quick non expert way might be:

OnClick Event of button
Me.ControlName1.Value = ""
Me.ControlName2.Value = ""
Me.ControlName3.Value = ""
Me.Refresh

But, hey, I'm no expert

But hope this helps
 
That wont work. I can't use " " I have critiera that states is null. So
then it kind of defites the purpose. Thanks for trying though
Chey
 
does it make a difference if what I want undone is on a subform?

No; your code will work fine. "Me" refers to whatever form contains
the code - whether that's a mainform or a subform.

John W. Vinson[MVP]
 
when i use this code it say improper use of Dirty. What does that mean. Am
I doing something wrong. I just want to press the command button and it
clear what i typed in.
Thanks
 
when i use this code it say improper use of Dirty. What does that mean. Am
I doing something wrong. I just want to press the command button and it
clear what i typed in.

If you JUST want to clear the form (restoring whatever was there on
the form when you opened it), you don't need to check for me.dirty -
just use

Private Sub cmdUndo_Click()
Me.Undo
End Sub

If that's not the case, please copy and paste your actual code, and
indicate where it is - on a Form? Subform? Bound or unbound?
Updateable or not? What's the purpose of the form?

John W. Vinson[MVP]
 
When I push the button it dosent clear it.
Okay
This is what I am trying to do. I have a command button on the main form
and then a subform where Travelers enter there information. They can press
on command button to continue or the cmdUndo button to clear the form of what
they just typed and close.
Thanks for your time
Chey
 
Hi,

Have you tried the Wizard?. You can create a button to undo a record.
 
When I push the button it dosent clear it.
Okay
This is what I am trying to do. I have a command button on the main form
and then a subform where Travelers enter there information. They can press
on command button to continue or the cmdUndo button to clear the form of what
they just typed and close.
Thanks for your time
Chey

If you're trying to clear *both* the Form and the Subform, it's a bit
more work! The moment you set focus to any control in the Subform, the
main form record is written out to disk and saved; the form is no
longer dirty, and cannot be Undone. Similarly, if you enter a record
on the Subform and set focus to the mainform (event to click a
button), that subform record is saved to disk; the form is not dirty,
and the record cannot be undone.

If you want to delete a record in this case, you must run a Delete
query (or perhaps two, depending on the setting of Cascade Deletes in
your relationships) to actually erase the stored record out of your
table (or tables).

John W. Vinson[MVP]
 
oh okay I understand. Then I guess what I am trying to do will not work. It
sounds to be to much risk.
Thanks for your help
 
Back
Top