troubleshooting Question

SetProperty Foreground Colour

Avatar of John Burdett
John Burdett asked on
Microsoft Access
5 Comments1 Solution172 ViewsLast Modified:
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
ASKER CERTIFIED SOLUTION
John Tsioumpris
IT Supervisor
Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros