Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2006
    Location
    Chicago area
    Posts
    4

    Question Unanswered: Change Colors Globally

    I have a 2003 Access Database. My company has changed names and rebranded and I am tasked with updating the Database with the new colors. I have the RGB specifications for each color and I was able to come up with the corresponding numeric value for the properties. However, there are hundreds of forms and pages that have to be updated. Is there a way to globally change everything. For instance is there a "find replace" function where I can say if color is 83041 than replace with 8935190? It sure would save a great deal of time.

    Thanks!

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Quote Originally Posted by lslavik View Post
    Is there a way to globally change everything. For instance is there a "find replace" function where I can say if color is 83041 than replace with 8935190? It sure would save a great deal of time.
    Not as easily as you descibe, but here's a solution that you can easily adapt to your needs:
    Code:
    Sub ChangeAllFormColours()
    
        Dim obj As AccessObject
        Dim dbs As Object
        Dim frm As Form
        Dim sec As Section
        Dim ctl As Control
        Dim i As Long
        
        Set dbs = Application.CurrentProject
        For Each obj In dbs.AllForms
            DoCmd.OpenForm obj.Name, acDesign
            Set frm = Forms(obj.Name)
            Set sec = frm.Section(acDetail)
            
            ' For the Detail section of the form.
            '
            If sec.BackColor = vbWhite Then sec.BackColor = vbGreen
            
            ' Try other sections (there is no Sections collection).
            '
            On Error Resume Next
            For i = acHeader To acPageFooter
                Set sec = frm.Section(i)
                If Err.Number = 0 Then
                    If sec.BackColor = vbWhite Then sec.BackColor = vbGreen
                Else
                    Err.Clear
                End If
            Next i
            On Error GoTo 0
    
            ' Loop in the Controls collection
            '
            For Each ctl In frm.Controls
                Select Case ctl.ControlType
                    Case acTextBox, acComboBox, acListBox
                        If ctl.BackColor = vbWhite Then ctl.BackColor = vbYellow
                    Case Else
                        ' other type of control
                End Select
            Next ctl
            Set frm = Nothing
            DoCmd.Close acForm, obj.Name, acSaveYes
        Next obj
    End Sub
    As usual, don't forget to make a backup of the original database first.
    Have a nice day!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •