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

Resetting a form 2

Status
Not open for further replies.

Stevo911

Technical User
Apr 26, 2005
33
0
0
ZA
Hi there

I have a form which updates a mini database in excel (2003).

Once details have been submitted by the form to the workbook, it would be good to have the option to reset the form i.e. reload the form with original blank text boxes, populated list boxes etc.

My question: is there a 'reset' type command?

I've tried to 'End' and then re-run the application but without success i think for obvious reasons.

Does anybody have another idea or appoach to this?

Any help is appreciated, thanks!
 
cantyou just loop through your controls, and set the values to ""

Chance,

Filmmaker, taken gentleman and [insert quote here]
 
I also couldn't found a 'quick' answer so I began working around that. In short, capture the need for a clearing of the form in a bolean global variable and when its true restart the form after closure.

i.e.
userform1 is opened by commandbutton1
module Globals holds the public declared variables

in module Globals add:
Public bClearForm As Boolean

in a module
Sub OpenClearForm1
START:
Load Userform1
Userform1.Show
If bClearForm = true Then bClearForm = False: GoTo START
End Sub

in commandbutton1
Private Sub Commandbutton1_Click
OpenClearForm1
End Sub

in userform1
Private Sub ClearForm
bClearForm = true
Unload Userform1
End Sub

now where you need to clear the form you place
ClearForm

Hopes this helps.
Have fun.
 
I have to go with Chance's suggestion here. You can create a separate procedure in the Userform module that contains code to "clear" the various input controls, then call this as needed. I use this technique regularly. I often create a single dialog (Userform) that is used for scrolling through records, deleting records and adding new records. When the user clicks a button to add a new record, one of the actions taken by my code is to call the procedure that clears the inputs. I prefer something like this to having the dialog being unloaded then re-displayed (along with whatever initialization is required).

My 2 cents.

Mike
 
Jsut added a FAQ faq707-6170



Chance,

Filmmaker, taken gentleman and [insert quote here]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top