Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Undo changes on a sub form

Status
Not open for further replies.

4321z

Programmer
Oct 21, 2003
45
0
0
GB
Hi,

I'm trying to undo changes on a sub form if the property 'Dirty' has been triggered but as soon as you move from the sub form back to the main form the 'Dirty' property is reset and the undo on the docmd is no longer usable, any suggestion?
 
Can you use the DoCmd in the form's dirty event as well as the subform's event, and just do DoCmd.Undo your subform[/]?

Stephen [infinity]
"Jesus saith unto him, I am the way, the truth, and the life:
no man cometh unto the Father, but by me." John 14:6 KJV
 
You cannot undo a (sub)form record when you have moved off it. The record has already been saved by then.

You need an Undo button on the subform itself.
 
Hmm, that makes sense.. Maybe instead of an undo, then you could use a method for deleting the last entered record if need be. Or are you wanting to "undo" the record from the table, or just clear the controls on the form? Clearing the controls on the form is actually not too difficult. I've picked up some code/ideas from a few different posts in here, a couple of which is where I asked for help on the subject. I have had some info from a few different users in here.. Here is an example of how you could do it (clearing the controls on the form/subform:

Code:
Private Sub cmdClearFormButton_Click()
  Dim ctl as Control
  Dim frm as Form

  For Each ctl In frm.Controls
    If TypeOf ctl is vbComboBox or vbTextBox or vbListBox Then
       ctl = vbNullString
    End If
  Next ctl
End Sub

Of course, I may not have the TypeOf list of names correct there, but you could easily find the correct context if that is not 100% correct. [wink]

Stephen [infinity]
"Jesus saith unto him, I am the way, the truth, and the life:
no man cometh unto the Father, but by me." John 14:6 KJV
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top