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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA Code to make form revert to it's inital settings?

Status
Not open for further replies.

Kumba1

Technical User
Aug 29, 2002
94
I have VBA Code that modify's controls/etc on my form... when the user is done, the click a button called "new"... currently all it does it close the form, then re-open it... I would like to know if there's a command to reset all the controls to what their static values are...
 
The form actually closes and then reopens. Is this because the property DataEntry is set to Yes? If you were to reset that to No and use RunCommand (acCmdRecordsGoToNew) it would accomplish the same thing but not require the form to be closed. To reset to some static values merely define a structure and reset to those values at the end of the 'New' button code. If you want to store properties of controls to be able to reset them you can.

Type ControlDefaults
MyControl1 As String
MyControl2 As Boolean
MyControl3 As Integer
End Type
Dim mCDefaults As ControlDefaults

Public Sub GetStates()
mCDefaults.MyControl1 = Me.txtControl1.RowSource
End Sub

Public Sub SetStates
Me.txtControl1.RowSource = mCDefaults.myControl
End Sub

Public OnCurrent
GetStates
End Sub

Public cmeNew_OnClick
RunCommand (acCmdRecordsGoToNew)
SetStates
End Sub -------------------------------------
scking@arinc.com
Try to resolve problems independently
Then seek help among peers or experts
But TEST recommended solutions
-------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top