iterate through controls

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do I iterate through all the controls on a form? Currently I have:

Dim ct AS Access.Control

For Each ct In Forms("frmMyForm").Controls
..code
Next ct

I get an error that it can't find the form when I'm in the form itself and
spelling looks correct.

Thanks
 
smk23 said:
How do I iterate through all the controls on a form? Currently I have:

Dim ct AS Access.Control

For Each ct In Forms("frmMyForm").Controls
..code
Next ct

I get an error that it can't find the form when I'm in the form
itself and spelling looks correct.

Thanks

I see nothing wrong with what you have, but I've always just used...

Dim ctl As Control

For Each ctl in Me
....
 
If the code's in the module associated with the form, you can use

For Each ct In Me.Controls
 
Back
Top