John Burdett
asked on
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.OpenRecor dset("Owne r 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
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.OpenRecor
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
I am under the impression your rst doesn't return the correct value...can you give a sample?
ASKER
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.OpenRecor dset("Owne r 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
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.OpenRecor
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That is perfect thank you. Just one final question how is the long value of 11361562
derived
derived
I saw it in the watch window....