So I'm trying to change the backcolor of a rectangle within Access. I know you can easily do this Box1.BackColor = RGB(0, 0, 0)
, however I want to enter a value into a textbox and then display that color value as soon as you update the textbox.
I thought the following would work, but it doesn't.
Textbox1 = 0, 0, 0
Dim P1 as String
P1 = "RGB(" + Textbox1.text + ")"
Box1.Backcolor = P1
How can I go about changing the backcolor on the fly?
You could
split
the text, run the entries thoughint
and feed it toRGB
:Based on your code, Eval() should work for you. The function evaluates a string as if were code. Backcolor is a long, btw so I adjusted your code accordingly.
Or you can ditch P1 and do this:
Depending on what you are doing, you might just want to use the built in color dialog instead of entering text in a textbox.
Here's the API declaration and re-usable function
And here would be your box call to these functions; it's passing the default color of the box so that will be chosen when the dialog is open.