Changing backcolour

T

Tony Williams

I'm trying to change the backcolour of all my forms and am using this code
in a module

Public Sub ChangeAllControlProps()
Dim dbCur As Database
Dim doc As Document
On Error GoTo ErrHandler

Set dbCur = CurrentDb
For Each doc In dbCur.Containers("Forms").Documents
DoCmd.OpenForm doc.Name, acDesign
Section.backcolor = RGB(255, 255, 255)
DoCmd.Close acForm, doc.Name, acSaveYes
Next doc
ExitHere:
Set dbCur = Nothing
Exit Sub

ErrHandler:
Select Case Err.Number
Case 438 'Property does not exist
Resume Next
Case Else
MsgBox Err.Number & " - " & Err.Description
Resume ExitHere
End Select
End Sub

It seems to run through all the forms but doesn't change the backcolour and
when it's finished running I get an error message
424-Object required
Anyone help me with this?
Thanks
Tony
 
B

Baz

This line looks wrong:

Section.backcolor = RGB(255, 255, 255)

You need to specify which form and which section e.g.:

Forms(doc.Name).Section(acDetail).backcolor = RGB(255, 255, 255)
 
T

Tony Williams

Thanks Baz that worked just fine! How would I amend that line to change the
backcolour of the form header?
Cheers
Tony
 
T

Tony Williams

And what about changing the backcolour of all tabcontrols?
Thanks, really appreciate this
Tony
 
T

Tony Williams

Hi Baz this gives an error message
2462-The section number you entered is invalid
Any ideas?
Thanks
Tony
 
M

missinglinq via AccessMonster.com

"2462-The section number you entered is invalid"

This is just a guess, but perhaps you have forms with the header height set
to zero?This might cause an error to be thrown when trying to set the
backcolor on a form section that, in reality, doesn’t exist.

As for changing the tabbed page colors, the prolific Stephen Lebans has a
workaround here:

http://www.lebans.com/tabcolors.htm
 
B

Baz

That's because it's found a form which doesn't have a header. Just trap the
error and ignore it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top