Color Fill Box in Forms

phatus

Registered User.
Local time
Today, 13:25
Joined
Nov 10, 2010
Messages
100
attached here is sample of a form contains name and color code...
problem: the color code box should be fill with a color you select now a word...

for example if the color code is red when you click the box a set of color will appear and if you select the red color it will fill the box...

i dunno how to do it, but is it possible?
 

Attachments

If the colours are going to be just the usual green, red, blue and yellow etc.. (based on what you currently have), then it can be done using the vb Color constants. If yes, then
Code:
Private Sub Color_Code_Click()
    Select Case Nz(Me.Color_Code, "")
        Case "red"
            Me.Color_Code.BackColor = vbRed
        Case "green"
            Me.Color_Code.BackColor = vbGreen
        Case "blue"
            Me.Color_Code.BackColor = vbBlue
        Case "yellow"
            Me.Color_Code.BackColor = vbYellow
        Case Else
            ' do nothing"
    End Select
End Sub

Normally you will either use the hex equivalent, the rgb() equivalent or the Long equivalent of the color and not just "RED".
 
got it sir but the WORD still appear... can it be hidden? only the color shows

and sir i notice too..

in the 3 forms

if i put red in form 1... the box filled with red, but when i go to form 2 which the color is green the it was fill with red unless i change it to green all the box in the 3 forms are the same color....

how can i make it by form only?

thank you...

phatus
 
Last edited:
for a sec sir ill attached a screen shot of the print preview... because in the print preview they all the same color...

can you modify my sample?

untitled-5.jpg
 
can you PLEASE modify my sample?
No, it cannot be done.

Your original form was set as a Single Form. If you initially mentioned it was a Continous form I would have told you this earlier.

Unless what you're really after is Conditional Formatting. Look into that.
 
ok sir i understand but its a continous form sorry for that... ill use the same code?
 
o ic i understand sir thanks a lot for the help...
 
No problemo!

There is a way but you would have to use something like a Collection or Dictionary object. It's just not straightforward.
 
No problemo!

There is a way but you would have to use something like a Collection or Dictionary object. It's just not straightforward.

can you give me a tutorial link about a dictionary object? or any sources so that i can study it... thanks again...
 

Users who are viewing this thread

Back
Top Bottom