M
Me.Frustrated = True
Hello everyone.
I have about 60 forms in my database, many with custom colors for the
Details/Header/Footer sections and the forms' controls. I tried to write a
sub to open each form in design view, change the colors back to the defaults,
so I wouldn't have to fix each form manually. But for some reason I can't
get this code to work:
------------------------------
Public Sub ReColor()
On Error GoTo err_code
Dim obj As AccessObject
Dim dbs As Object
Dim ctl As Control
Set dbs = Application.CurrentProject
For Each obj In dbs.AllForms
DoCmd.OpenForm obj.Name, acDesign
Debug.Print obj.Form.Section(0).BackColor
With obj
.Form.Section(0).BackColor = -2147483633
.Form.Section(1).BackColor = -2147483633
.Form.Section(2) = -2147483633
For Each ctl In obj.Controls
If ctl.ControlType = acTextBox Or ctl.ControlType = acComboBox
Then
ctl.BackColor = -2147483643
ctl.ForeColor = -2147483640
End If
Next ctl
End With
DoCmd.Save acForm, obj
DoCmd.Close
Next obj
exit_here:
Exit Sub
err_code:
MsgBox (Err.Number & ": " & Err.Description)
Resume exit_here
End Sub
I have about 60 forms in my database, many with custom colors for the
Details/Header/Footer sections and the forms' controls. I tried to write a
sub to open each form in design view, change the colors back to the defaults,
so I wouldn't have to fix each form manually. But for some reason I can't
get this code to work:
------------------------------
Public Sub ReColor()
On Error GoTo err_code
Dim obj As AccessObject
Dim dbs As Object
Dim ctl As Control
Set dbs = Application.CurrentProject
For Each obj In dbs.AllForms
DoCmd.OpenForm obj.Name, acDesign
Debug.Print obj.Form.Section(0).BackColor
With obj
.Form.Section(0).BackColor = -2147483633
.Form.Section(1).BackColor = -2147483633
.Form.Section(2) = -2147483633
For Each ctl In obj.Controls
If ctl.ControlType = acTextBox Or ctl.ControlType = acComboBox
Then
ctl.BackColor = -2147483643
ctl.ForeColor = -2147483640
End If
Next ctl
End With
DoCmd.Save acForm, obj
DoCmd.Close
Next obj
exit_here:
Exit Sub
err_code:
MsgBox (Err.Number & ": " & Err.Description)
Resume exit_here
End Sub