Changing the colour of a box.

J

John Ortt

Hi everyone,

I have a table with lots of different objects and each one has a colour
defined in Hex and RGB format.

The problem is that I would like to use the relevant colour on my access
form but I don't have the access colour code.

Is there a way I can convert hex or RGB into access colour codes.

(I realise there are lots of websites giving this info if you type it in but
I would not like to do it in access).

Thanks,

John
 
J

John Ortt

For info, this is the code I tried where strColour is something like
"(255,0,0)":

Private Sub Form_Current()
Dim thecolour As String
thecolour = "RGB" & Me![strColour]
MsgBox thecolour
Me.ColourBox.BackColor = thecolour.Text
Hex
End Sub
 
S

Stephen Lebans

John if you search via GoogleGroups for something like:
Lebans convert RGB hex

You should get several pertinent threads containing the desired sample code.
http://groups.google.ca/groups?as_q=lebans+convert+rgb+hex&num=10

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


John Ortt said:
For info, this is the code I tried where strColour is something like
"(255,0,0)":

Private Sub Form_Current()
Dim thecolour As String
thecolour = "RGB" & Me![strColour]
MsgBox thecolour
Me.ColourBox.BackColor = thecolour.Text
Hex
End Sub


John Ortt said:
Hi everyone,

I have a table with lots of different objects and each one has a colour
defined in Hex and RGB format.

The problem is that I would like to use the relevant colour on my access
form but I don't have the access colour code.

Is there a way I can convert hex or RGB into access colour codes.

(I realise there are lots of websites giving this info if you type it in
but I would not like to do it in access).

Thanks,

John
 
J

John Ortt

Thanks for the help Stephen, it was a big help and it has shown me that I am
on the right track...

Even though I think I have figured out the problem, I can't figure out how
to correct it.

From the link you have posted I believe I am able to use the RGB values as
demonstrated in my code.

The problem is that the values are being passed as:

Me.ColourBox.BackColor = "RGB(255,0,0)"

rather than:

Me.ColourBox.BackColor = RGB(255,0,0)

I don't know how to get it to interpret it without the quotes?!

Any ideas?

Thanks in advance,

John
 
J

John Ortt

SOLVED! :)

I have broken the RGB values up into separate fields for each component and
then used the following code:

Private Sub Form_Current()
Me.ColourBox.BackColor = RGB(Me![bytColourR], Me![bytColourG],
Me![bytColourB])
End Sub

And it works fine now. Didn't seem to like the commas being a part of the
assigned value.

Thanks for the help,

John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top