controls on forms

  • Thread starter Thread starter Ramone
  • Start date Start date
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
 
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.
 
Back
Top