View Full Version : Properties


Joshann
04-17-2002, 01:43 PM
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!

Jack Cowley
04-17-2002, 04:10 PM
Search help for Control Object. There is sample code there to do what you want.

Joshann
04-18-2002, 05:59 AM
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

Jerry Stoner
04-18-2002, 07:05 AM
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

Joshann
04-18-2002, 07:22 AM
That's exactly what I was looking for. Thanks so much!

Jerry Stoner
04-18-2002, 07:24 AM
Youre welcome