Properties

Joshann

Registered User.
Local time
Today, 13:40
Joined
Mar 22, 2002
Messages
142
Is there a way to reference all the controls on a form without specifying each control name? If a certain event happens, I want to be able to change the Enabled property on all the controls on the form with having to say controlname.enabled = True for every control on the form.

Any help would be greatly appreciated!
 
Search help for Control Object. There is sample code there to do what you want.
 
Thanks but I looked and didn't find what I'm looking for. The code below changes a property on all of the forms in a project without naming each form. I'm looking for something similar that will change a property on each of the controls on a specific form.

Dim objFrm As AccessObject, frm As Form
For Each objFrm in CurrentProject.AllForms
DoCmd.OpenForm FormName:=objFrm.NAME, View:=acDesign
Set frm = Forms(objFrm.NAME)
frm.Toolbar = "MyToolbar"
DoCmd.RunCommand acCmdSave
DoCmd.Close acForm, objFrm.NAME
Next objFrm
 
Dim frmMyForm As Form
Dim ctlMyCtls As Control
Set frmMyForm = Forms!fMyWonderfulForm

' To turn on the whole group:
For Each ctlMyCtls In frmMyForm.Controls
ctlMyCtls.Enabled = True
Next ctlMyCtls
Set frmMyForm = Nothing
 
That's exactly what I was looking for. Thanks so much!
 

Users who are viewing this thread

Back
Top Bottom