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

Resetting Form

Status
Not open for further replies.

comicwizard

Technical User
Joined
Mar 28, 2011
Messages
2
Location
US
Good day, I have a form with several triggers,radial buttons and combo boxes. I would like a way of resetting the form. I thought of using the esc key but I think that would be messy. What I mean by resetting is that I have some radial buttons when choosen disable some combo boxes to prevent them from being used. I would like a way of get the form reset so all fields are available.
 

Let's say on your Form you have:
a combo box named cboMyCombo
some option (radio) buttons, by default optOne is selected
a command button called cmdReset
Code:
Option Explicit

Private Sub UserForm_Initialize()
    Call StartMyForm
End Sub

Private Sub cmdReset_Click()
    Call StartMyForm
End Sub

Private Sub StartMyForm()

With cboMyCombo
    .Clear
    .AddItem "One"
    .AddItem "Two"
    .ListIndex = 0
End With

optOne.Value = False
optOne.Value = True

End Sub
You can set whatever you want in StartMyForm procedure called from UserForm_Initialize event, and if you want to reset it all to its original state, call it from your cmdReset_Click event.

Would that work for you?

Have fun.

---- Andy
 
Andy, I guess the OP has an AccesForm, not an UserForm ...
 

You may be right PHV, but I would think the same logic would apply: set all initial settings in some procedure and call this procedure at the beginning of the project, and from some Reset button.

Have fun.

---- Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top