Clearing data from a form

E

ersouthard

I am creating a database for entering productivity data. There is a
different data entry form for each category of information. Each form has
anywhere from 63 to 84 unbound text boxes (formatted as fixed). Each box has
0 as the default value.

Inevitably, someone is going to fill in a form and realize the data is
incorrect and they need to start over.

My question is, is there a simple way to setup a command button that they
could click and reset the form to all zero's? I know I could write code like
the following but I don't want to have to write all the code.

text0 = 0
text1 = 0
text2 = 0
so on and so on...

Any suggestions?
 
D

Douglas J. Steele

If your text boxes are named text1, text2, text3 through text84, use:

Dim intLoop As Integer

For intLoop = 1 To 84
Me.Controls("text" & intLoop) = 0
Next intLoop

If your text boxes don't have any consistent naming scheme, you can use the
Tag propertly to indicate which ones should be reset. (The Tag property is a
free-form text property that can be used to store anything you want). You'd
put something like Reset as the tag property for each of the text boxes
(hint: If you select them all and put it in the Tag property in the
Properties window, it will set the property for each of the selected text
boxes at once), and then use code like

Dim ctlCurr As Control

For Each ctlCurr In Me.Controls
If ctlCurr.ControlType = acTextBox Then
If ctlCurr.Tag = "Reset"
`ctlCurr = 0
End If
End If
Next ctlCurr
 
E

ersouthard

Thanks for the reply. I ended up going with the Tag example the previous
gentleman posted, however, yours no doubt would work just as well.

As for using Unbound controls, when I started using Access about 10 years
ago I had trouble working with Bound controls and seemed to be able to
control how the users handled data easier with Unbound controls. I guess I
just got comfortable working with the Unbound controls.

Thanks again!
 

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