How do I programatically change the background color of a frame in ms/access 2007 (VBA)?

João serras-pereira
João serras-pereira used Ask the Experts™
on
I have a piece of  code in ms/access VBA and wand t change the background color of a frame according to the value of a variable as in the code below:

   If [9003_ExcedentarioSN] Then
        LblExcedentario.BackColor = "#FF6600"
     Else
         LblExcedentario.BackColor = #ECECEC"
     End If

but it won't accept as  '#FF6600' is not valid type for the method. I guess I need to use another method. Wich? Can anyone help?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems Analyst
Top Expert 2007

Commented:
You need to use either the RGB() or Access color number equivalent.

mx
Database Architect / Systems Analyst
Top Expert 2007
Commented:


   If [9003_ExcedentarioSN] Then
        LblExcedentario.BackColor = RGB(255,102,0)
     Else
         LblExcedentario.BackColor = RGB(236,236,236)
     End If
gee thanks!!!
Should you be charging more for IT Services?

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems Analyst
Top Expert 2007

Commented:
Just for an FYI ... here is how to get the Access color number:

See this link:

http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_21919798.html#a17110384

http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_24120771.html#a23574933

http://www.tayloredmktg.com/rgb/#BL 'The Other RGB Color Chart

Access Color = R + G*256 + B*256^2

? 255.0 + 255.0*256 + 255.0*256^2 = 16777215  = White

Also:

QBColor Function
     
Returns a Long representing the RGB color code corresponding to the specified color number.

mx
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems Analyst
Top Expert 2007

Commented:
Also, if you have Photoshop or other similar program, you can convert those Hex numbers to RGB ... which is how I did it above.

mx
tthanks again to all!
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems Analyst
Top Expert 2007

Commented:
There was only one of us :-)

You are welcome.

mx

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial