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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

For each Control : Enable controls

Status
Not open for further replies.

fogal

Technical User
Aug 20, 2001
87
US
I want to enable all controls etc....

Code below geneertaes an error
I then want to use this on the filter action of a form.

Dim frm As Form, ctl As Control
Set frm = Forms!frm_nonroutineoperations

For Each ctl In frm.Controls
ctl.Enabled = True
ctl.Locked = False
ctl.BackColor = 16777215
Next ctl
 
Hi

What error message do you get ? On which line ?
You might be trying to set a property for a control that doesn't accept that property,for example, you can't enable a label.
You would need to include something like :
if frm.control <> aclabel

regards
 
The best way to do this is also to have a loop for the properties to see if enabled exists.

i.e.

Dim frm As Form, ctl As Control, prp as Property

Set frm = Forms!frm_nonroutineoperations

For Each ctl In frm.Controls
For Each prp in ctl
If prp.Name = &quot;Enabled&quot; Then
ctl.Enabled = True
ElseIf prp.Name = &quot;Locked&quot; Then
ctl.Locked = False
End If
Next prp
Next ctl

Hope that helps.

Craig
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top