Change BackColor of All Forms via Code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Does anyone know how I can change the backcolor (or even the font) of all forms in an ms access db via code either through a function or sub routine

Any help would be much appriacated.
 
Hi Ben,

Here is some simple code that loops through all forms and changes the
background color of the detail section (you might want to add code for
changing the header and footer sections as well). Use with caution!

Sandra Daigle

Public Sub ChgBackColor()
' Comments :
' Parameters: -
' Modified : 07/31/2000 SMD
'

On Error GoTo Proc_Err
Dim dbs As DAO.Database
Dim doc As Document
Dim lngI As Long
Set dbs = CurrentDb
lngI = 1
For Each doc In dbs.Containers("Forms").Documents
DoCmd.OpenForm doc.Name, acDesign
Forms(doc.Name).Section(acDetail).BackColor = 8454143
lngI = lngI + 1
If (lngI Mod 15 = 0) Then
DoEvents
End If
DoCmd.Close acForm, Forms(doc.Name).Name, acSaveYes
Next

Proc_Exit:
Set doc = Nothing
Set dbs = Nothing
Exit Sub

Proc_Err:
MsgBox Err.Number & vbCrLf & Error$
Resume Next
End Sub
 
So that doevents is only fired every 15th iteration - I could have just as
easily tested for intI=15 and then reset it to 0 on each 15th iteration. I
latched on to this method and just keep using it.
 
Back
Top