Loop through all controls on a form

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

Guest

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.
 
-----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
 
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
 
Back
Top