Loop through objects changing background color of certain kinds ofobjects

  • Thread starter Thread starter BrianDP
  • Start date Start date
B

BrianDP

I think that sums it up. If someone can help me, TIA.

Just to clarify- I have several forms- and I want to run a program
that will look at each one, and on each form, if the type of object is
a Header, Form, Footer, or Label, change it's background to a given
color.

Something like For each object in objects...? The syntax excapes me
at the moment.

-BrianDP
 
Is something like this what you're looking for?
Dim frm As AccessObject 'Temporary form
Dim fSuccess As Boolean 'Have we been successful?
'Initialize
fSuccess = True
For Each frm In CurrentProject.AllForms
fSuccess = fSuccess And FormSetBackgroundColor(frmName:=frm.Name)
Next frm

In FormSetBackgroundColor() you can loop through the Controls collection to
find labels. I don't think there is a Sections collection, but there are
indexes for each standard section type (Form Header, Page Header, Detail,
etc.).

In you can dimension frm as Access.Form:
Dim frm As Access.Form 'Form we're processing
'Open the form in design mode so we can access control properties
DoCmd.OpenForm FormName:=frmName, View:=acDesign
Set frm = Forms(frmName)
 
Back
Top