undo

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
 
G

Guest

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
 
G

Guest

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
 
J

John Vinson

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]
 
G

Guest

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
 
J

John Vinson

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]
 
G

Guest

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
 
A

AccessVandal via AccessMonster.com

Hi,

Have you tried the Wizard?. You can create a button to undo a record.
 
J

John Vinson

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]
 
G

Guest

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
 

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

Similar Threads

Can't undo? 3
Save Record Dilema! 2
Dirty Method 5
Acc 2007: Me.Undo Not Working 3
Slight change to Script! 1
Undo Button 2
if duplicate goto record 3
Suppress MsgBox 7

Top