Changing Colour of ALL forms in database

  • Thread starter Thread starter ant1983
  • Start date Start date
A

ant1983

Hi,

I would like to have an option in a menu where I can change the back colour
of all my forms in my database.

It should change every last form in the database to the same colour.

How can this be done?

Thanks,

Wayne
 
Wayne, the forms don't have a color; their sections do.

This (untested) example will change the BackColor of all sections in all
forms to white, and save them without asking:

Function ChangeForms()
Dim accObj As AccessObject
Dim frm As Form
Dim strName As String
Dim i As Integer
Const lngcBackColor = vbWhite

For Each accObj In CurrentProject.AllForms
strName = accObj.Name
DoCmd.OpenForm strName, acDesign
Set frm = Forms(strName)
For i = 0 To 20
If HasSection(frm, i) Then
frm.Section(i).BackColor = lngcBackColor
End If
Next
DoCmd.Close acForm, strName, acSaveYes
Next
End Function

Private Function HasSection(obj As Object, iSection As Integer) As Boolean
Dim strDummy As String
On Error Resume Next
strDummy = obj.Section(iSection).Name
HasSection = (Err.Number = 0&)
End Function
 
What do i do with that code? Do i creat a command button and paste it in the
on-click event of that button? If so, nothing happens - Please advise.

Cheers!
 
1. Open the code window.

2. Choose Module on the Insert menu.
Access opens a new module.

3. Paste the code in there.

4. Verify Access understands it: choose Compile on Debug menu.

5. Open the Immediate Window (Ctrl+G), and enter:
? ChangeForms()
 
Back
Top