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
 

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

Back
Top