Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / November 2007

Tip: Looking for answers? Try searching our database.

change label backcolor on all forms

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ToniS - 16 Nov 2007 18:45 GMT
I have an .adp application and I would like to add an interface to allow the
user to change the color for all labels on all forms.  I am already using the
AllForms object to change the title on each form based on the user selection
and that works fine.  
I am not sure how to add the same type of logic for all labels..   My naming
convention for all lables is as follows: they all start with 'lbl'

Any suggestions would be greatly appreciated

Thanks
ToniS
fredg - 16 Nov 2007 21:22 GMT
> I have an .adp application and I would like to add an interface to allow the
> user to change the color for all labels on all forms.  I am already using the
[quoted text clipped - 7 lines]
> Thanks
> ToniS

Open each form (you can use the same procedure you are using to change
the name of the form) in Design View. Cycle through the controls. If
the control is a Label control, change it's backcolor. Then save the
form changes and go on to the next form.

Incorporate the below snippet of code into your current code that
cycles through the form collection to change the form name.

frmName is whatever name you have called this form.

DoCmd.OpenForm frmName, acDesign, , , , acHidden

Dim ctl as Control
  For each ctl in Controls
     If TypeOf ctl is Label then
    ctl.BackColor = vbBlue
     End If
  Next ctl
DoCmd.Close acForm, frmName, acSaveYes

Continue looping through the forms collection to get the next form.

   
Signature

Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail

ToniS - 16 Nov 2007 22:22 GMT
Thanks I think this is exactly what I am looking for, unfortunately I am not
sure what I am doing wrong....  The titles change correctly but the colors do
not, I did test the IntBackColor by setting  
Forms(obj.Name).LblTitle.backcolor = intbackcolor and that did work...

What is the purpose of the DoCmd.OpenForm and Close?  I did not need that
for changing the title on each form?    FYI: The below code is located in
module1 in a public sub....

Below is what I have.

Dim obj As AccessObject
Dim ctl As Controls
Dim dbs As Object

   DoCmd.OpenForm Form_Frm_Maintenance_CurrentShow, acDesign, , , , acHidden
   
   For Each obj In dbs.AllForms
       Forms(obj.Name).LblTitle.Caption = strTitle
   
'       For Each ctl In Controls
       For Each ctl In dbs.AllForms.Controls
           If TypeOf ctl Is Label Then
'                ctl.BackColor = vbBlue
'                ctl.BackColor = intbackcolor
               dbs.AllForms.Controls.ctl.BackColor = intBackcolor
           End If
       Next ctl
   Next obj
   
   DoCmd.Close acForm, Form_Frm_Maintenance_CurrentShow, acSaveYes

> > I have an .adp application and I would like to add an interface to allow the
> > user to change the color for all labels on all forms.  I am already using the
[quoted text clipped - 31 lines]
>
>    
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.