Loop through all controls on a form

S

SHIPP

I would like to loop though all controls on a form to disable all of them. Anybody have the code to do this. I'm using Access 97.
 
J

Jason

-----Original Message-----
I would like to loop though all controls on a form to
disable all of them. Anybody have the code to do this. I'm
using Access 97.


Dim Frm as Form, Ctl as Control

Set Frm = Me
For Each Ctl In Frm
Ctl.Enabled = False
Next Ctl

Jason
 
M

Marshall Barton

SHIPP said:
I would like to loop though all controls on a form to disable all of them. Anybody have the code to do this. I'm using Access 97.


Some controls can not be enabled/disabled so you either have
to check the controls type or ignore the errors that occur.
Here's one way:

Dim ctl As Control
On Error Resume Next
For Each ctl in Me.Controls
ctl.Enabled = False
Next ctl
 

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