SetProperty Foreground Colour

I am trying to set label colours dependant on a value set by a user in a table.

When I assign for example RGB(26, 93, 173) to variable teamcolour. SetProperty works fine with this and makes the font blue. However when I fetch the same value from a table the font is black. I have tried Dlookup  and recordsets. In both cases the variable holds the value RGB(26, 93, 173) but appears not to use it or evaluates it to 0. Why is this?

 The code I am using is as follows:
    Dim dbsPlayerProfile As DAO.Database
    Dim rstOwnerTeam As DAO.Recordset
    Dim TeamColour As String
    Dim ColourTeam
 
   Set dbsPlayerProfile = CurrentDb
   Set rstOwnerTeam = dbsPlayerProfile.OpenRecordset("Owner Team")
 
   rstOwnerTeam.MoveFirst
   TeamColour = rstOwnerTeam!Colour.Value

    DoCmd.SetProperty "Label0", acPropertyForeColor, TeamColour
    DoCmd.SetProperty "League", acPropertyForeColor, TeamColour
    DoCmd.SetProperty "Owner Team", acPropertyForeColor, TeamColour

rstOwnerTeam.Close
' This produces black font

-------------

When I set the value in the code however as follows:

    Dim TeamColour
    DoCmd.SetProperty "Label0", acPropertyForeColor, TeamColour
    DoCmd.SetProperty "League", acPropertyForeColor, TeamColour
    DoCmd.SetProperty "Owner Team", acPropertyForeColor, TeamColour

' This produces blue
John BurdettAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

John TsioumprisSoftware & Systems EngineerCommented:
I am under the impression your rst doesn't return the correct value...can you give a sample?
0
John BurdettAuthor Commented:
The Table Owner Team has only one record and contains a field colour which hold the value RGB(26, 93, 173) and this is displayed when I use the msgbox

This is all the code I was using

    Dim dbsPlayerProfile As DAO.Database
    Dim rstOwnerTeam As DAO.Recordset
    Dim TeamColour As String

 
   Set dbsPlayerProfile = CurrentDb
   Set rstOwnerTeam = dbsPlayerProfile.OpenRecordset("Owner Team")
 
   rstOwnerTeam.MoveFirst
   TeamColour = rstOwnerTeam!Colour.Value


 
   
           
    DoCmd.SetProperty "Label0", acPropertyForeColor, TeamColour
    DoCmd.SetProperty "League", acPropertyForeColor, TeamColour
    DoCmd.SetProperty "Owner Team", acPropertyForeColor, TeamColour
   
    MsgBox (TeamColour)

  rstOwnerTeam.Close
0
John TsioumprisSoftware & Systems EngineerCommented:
I guess you are reading it as a set of integers or a string....but RGB is a long so you must provide the correct Long interpretation....
So for example (this will give a nice blue color)
DoCmd.SetProperty "Label0", acPropertyForeColor,11960589

Open in new window

EDIT i just saw your RGB values so this what you need
DoCmd.SetProperty "Label0", acPropertyForeColor,11361562

Open in new window

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 BurdettAuthor Commented:
That is perfect thank you. Just one final question how is the long value of 11361562
derived
0
John TsioumprisSoftware & Systems EngineerCommented:
I saw it in the watch window....
1
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.