- Local time
- Today, 04:32
- Joined
- Feb 19, 2013
- Messages
- 17,391
I'm having one of those days, something I thought would be simple has led me into a circle of confusion.
. I'm using Access 2010
What I want to be able to do is to assign a back colour to a control from VBA. There are many colours and what I thought would be an easy process was to choose a suitable colour to be assigned using the colour picker for a control, note the hex number then in my vba code would be
This compiles OK, but produces a completely different colour - I'm expecting an orange colour but getting blue and in another example a pale blue is coming out a brown.
research indicates adding an ampersand to the end changes the value from integer to long but if I type
In the immediate window
?&HF0AD34
?&HF0AD34&
?Val("&HF0AD34")
?clng("&HF0AD34")
?Val("&HF0AD34&")
?clng("&HF0AD34&")
All produce the same value of 15772980, which if I copy back to the control backcolour property produces the blue colour and not the required orange - which if i debug.print me.mycontrol.backcolor give me 3452400 - the correct number for orange.
The problem seems to be converting the hex number to a long.
I'm sure I'm missing something really simple, but I can't see it - any suggestions?
Also happy to modify the properties window to show the decimal value rather than the hex value, but can't see anywhere to do this

What I want to be able to do is to assign a back colour to a control from VBA. There are many colours and what I thought would be an easy process was to choose a suitable colour to be assigned using the colour picker for a control, note the hex number then in my vba code would be
if... then me.mycontrol.backcolor=&HF0AD34
This compiles OK, but produces a completely different colour - I'm expecting an orange colour but getting blue and in another example a pale blue is coming out a brown.
research indicates adding an ampersand to the end changes the value from integer to long but if I type
the second ampersand disappears.if... then me.mycontrol.backcolor=&HF0AD34&
In the immediate window
?&HF0AD34
?&HF0AD34&
?Val("&HF0AD34")
?clng("&HF0AD34")
?Val("&HF0AD34&")
?clng("&HF0AD34&")
All produce the same value of 15772980, which if I copy back to the control backcolour property produces the blue colour and not the required orange - which if i debug.print me.mycontrol.backcolor give me 3452400 - the correct number for orange.
The problem seems to be converting the hex number to a long.
I'm sure I'm missing something really simple, but I can't see it - any suggestions?
Also happy to modify the properties window to show the decimal value rather than the hex value, but can't see anywhere to do this