Clear unbound textbox controls


G

Guest

I have a procedure that get's called that I want to clear all values in all
text controls. I saw a post by Dirk Goldgar that appears to have solved this
question for TataKau but I keep getting "You can't assign a value to this
object" error. I'm using Access 2003.

Thanks for your help
LeAnn

--------Dirk's code-------------------------------------------
Dim ctl As Access.Control

For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Then
ctl.Value = Null
End If
Next ctl
 
Ad

Advertisements

G

Guest

It is most likely you have one or more of your text boxes that has some
property settting that prevents it from being updatable.
I would suggest you set a breakpoint on this line:
If ctl.ControlType = acTextBox Then
check the value of ctl.Name before each execution. When you get the error,
you will know which text box is the offender. Check that control's
properties to see if anything is preventing it from being updated.
 
G

Guest

Yes, I did think that it was a property and thought it was the fact that most
are disabled controls but turns out that's no problem. With your suggestion
I did find the culprit(s). I have several textbox that have functions in the
control source which seems to prevent the value from being cleared. How can
I skip those in the loop? 4 of their names end with “Time†and 4 end with
“Excâ€

Thanks
 
Ad

Advertisements


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