controls on forms

R

Ramone

Can someone give me the code I can use to refer to all
the controls on my form. When I get to the last record I
would like the form to clear all the controls.

Thanks for any help
 
N

Neil

You can loop through the controls on a form. My example prints the name of
each control in the immediate window but only if it is a textbox.

--------------------------

Dim ctl As Control
' Loop through the controls
For Each ctl In Me.Controls
' Check the type of the control
If TypeOf ctl Is TextBox Then
' Print the name
Debug.Print ctl.Name
End If
Next

--------------------------

Replace Me.Controls with Forms!YourFormName.Controls if the code isnt
located in the forms module.

HTH,

Neil.
 

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