Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disable all controls in from upon opening...?

Status
Not open for further replies.

Klopper

MIS
Dec 7, 2000
84
US
I would like to disable each control in a form when the form is opened - can anyone tell me why this code does not work?

Private Sub Form_Open(Cancel As Integer)
Dim ctl As Control
Dim frm As Form

Set frm = Forms!form_name

For Each ctl In frm.Controls
ctl.Enabled = False
Next ctl

End Sub

Any help appreciated!
Klopper
 
Hi!

Try putting the code in the Form_Load event instead. I'm not sure that all of the controls are available for the open event.

hth
Jeff Bridgham
 
Good suggestion, Jeff, but it didn't quite work.
For some reason, the "enabled" propery is not available but the "visible" property is!
This does the job but seems a little odd to a novice like me.

TFTH
Klopper

 
Why not disable them in design view. That way when you open the form they are disabled. When you need to get at the fields, run your code to enable them.
 
Yup, that works!

Why is it that the most trivial things lose you the most amount of hair?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top