Form Background colour change

Access 2003 , I have a form which is light grey background and I wish to change this background colour for the form
based on a field within the form. The field is a Y or N called 'Invoiced' .
So if invoiced = y form should change colour if = N no change.

Many Thanks for any help
John PikeConsultant SystemsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongCommented:
for example, in the Form_Current event, try add:
Private Sub Form_Current()
    If iniColor = 0 Then iniColor = Me.BackColor
     If Invoiced.Value = "Y" Then
       'Set the color you want
        Me.BackColor = RGB(255, 0, 0)
    Else
        Me.BackColor = iniColor
    End If
End Sub

Open in new window

In a public Module:
Public iniColor As Long

Open in new window

or you probably can do it via Conditional Formatting in Access.
0
John PikeConsultant SystemsAuthor Commented:
Thanks Ryan but it comes back with a compile error
'Method or data not found and halts on the first If line at   .BackColor

Regards
0
John PikeConsultant SystemsAuthor Commented:
sorry it says  Data Member not found
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Ryan ChongCommented:
sorry, try this instead.
Public iniColor As Long

Private Sub Form_Current()
    If iniColor = 0 Then iniColor = Me.Section(acDetail).BackColor
    If Invoiced.Value = "Y" Then
        'Set the color you want
        Me.Section(acDetail).BackColor = RGB(255, 0, 0)
    Else
        Me.Section(acDetail).BackColor = iniColor
    End If
End Sub

Open in new window

0
John PikeConsultant SystemsAuthor Commented:
Hi Ryan
This works when it finds a reord with  Invoiced = "Y" but when the next record
has Invoiced="N" it does not change back

Have I missed something

regards
0
John PikeConsultant SystemsAuthor Commented:
for your info Original Form Colour = RGB 219,219,219
changed colour is 179,179,179
0
Ryan ChongCommented:
hi, I tested it works fine in local my environment. hence, you mentioned the original form color is: RGB 219, 219, 219, you probably can try this as well:

Private Sub Form_Current()
    If Invoiced.Value = "Y" Then
        'Set the color you want
        Me.Section(acDetail).BackColor = RGB(179, 179, 179)
    Else
        Me.Section(acDetail).BackColor = RGB(219, 219, 219)
    End If
End Sub

Open in new window


let me know if that works, else I may need to upload a sample for you for demonstration.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
John PikeConsultant SystemsAuthor Commented:
Ryan,
many thanks that appears to work a treat...excellent
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.