Clearing Unbound Fields In Form

G

Guest

Hello,
I am trying to write a function that will clear all the text boxes in a form
and have been having trouble getting the following code to run:

Dim ctl as Control

For Each ctl in Me.Controls
If ctl.ControlType = acTextBox Then
ctl.Value = Null
End IF
Next ctl

For one thing, I am not seeing ControlType or Value as a member of Control
so I suspect this as the main problem. Am I missing a refence? Is there a
better way to do this?

Thanks,

Scott S
 
F

fredg

Hello,
I am trying to write a function that will clear all the text boxes in a form
and have been having trouble getting the following code to run:

Dim ctl as Control

For Each ctl in Me.Controls
If ctl.ControlType = acTextBox Then
ctl.Value = Null
End IF
Next ctl

For one thing, I am not seeing ControlType or Value as a member of Control
so I suspect this as the main problem. Am I missing a refence? Is there a
better way to do this?

Thanks,

Scott S

Dim ctl as Control
For Each ctl in Me.Controls
If TypeOf ctl is Textbox Then
ctl = Null
End IF
Next ctl
 
G

Guest

Thanks for the response. When I tried it I get an error message:

"Object doesn't support this property or method"

If I look at Control in the Object Browser I don't see any properties that
deal with type or value. I am looking at "Class Control - a member of
Access. Do I need to use a different reference?

Thanks again for your help.

Scott
 

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