clearing text boxes?

C

cityofgp

I have a form with several text boxes (unbound).
User enters values into them and clicks on the save button to write that
data to a table.
I want the text boxes to clear out as soon as the save button is clicked..I
cant seem to do that...
Any ideas?

I noticed that when the form loads from a start, all the boxes are
empty....perhaps I can somehow get the form to exit and reload again? Or is
there a simpler way of clearing all the text boxes?
 
M

Martin Seelhofer

Hi there
I noticed that when the form loads from a start, all the boxes are
empty....perhaps I can somehow get the form to exit and reload again? Or
is
there a simpler way of clearing all the text boxes?

You might want to try some code like the following (in the
button-click-handler):

Dim ctrl as MSForms.Control
For Each ctlr in Me.Controls
If TypeOf ctrl is MSForms.TextBox Then
' reset if the current control is a textbox:
ctrl.value = ""
End If
Next
 
C

cityofgp

Well I tried something similar to this already.....
For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Then
ctl.Value = ""
End If
Next

I get the following error message when it comes to ctl.value=""

Runtime error '2448'
You cant assign a value to that object
 

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