Clearing a form?

E

Ed from AZ

I have a form with unbound controls: two list boxes with the second
dependant on the first, a series of combo boxes, and several text
boxes. Is there one easy command to use that will reset the form to
the way it is when it first opens - nothing selected in the first list
box, and the second list box and all combo and text boxes blank? Or
do I need to go through each control and individually reset them?

Ed
 
J

Jeff Boyce

There's a lot I don't know about Access yet, so see if someone else here has
an elegant solution...

I build myself a function that steps through each control on a form and
'empties' it/them if they are textboxes, comboboxes, or listboxes.

Then I call that function from a <Clear> or <Undo> button click, and include
any other screen-prep needed ... for example, if I have an option group that
needs re-setting to a default choice, etc.

(but if there's a "wipe clean" command, I'm all ears!)

--
Regards

Jeff Boyce
www.InformationFutures.net

Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/
 
K

Ken Sheridan

A variation on Jeff's solution:

First set the Tag property of each control toy want clear to ClearMe, then
use the following code, e.g. in the event procedure of a 'Reset' button:

Dim ctrl As Control

For Each ctrl In Me.Controls
If ctrl.Tag = "ClearMe" Then
ctrl = Null
End If
Next ctrl

You may also have to add the following line to requery the second
(correlated) list box:

Me.YourSecondListBox.Requery

Ken Sheridan
Stafford, England
 
S

stfcTerryA

Hi Ed

I use the following code to clear cascading combo boxes and text fields on
my first combo box_AfterUpdate() Event:

Private Sub cboNumber1_AfterUpdate()

blar blar blar other code i've written then ....

Me!cboNumber2 = Null
Me!cboNumber3 = Null
Me!txtBoxNumber1 = Null

End Sub

Where cboNumber2 = the name of the combo box i wish to clear etc.

Maybe useful

Cheers
Terry - Oxford UK
 

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

Top