conditional formatting vba code for a split/datasheet form?

Z

zmenloans

Hi,

Sorry about my beginner ability, but I have a question. I have a combo box
in a split form, and for each of the 10 values possible to choose in the
combo box (called Color_Codes), I want the ID field to change colors. For
example, if "Paying" is chosen, I want the ID field to turn green.
"Restructure" = purple, "SBA" = pink, "Follow-Up" = gray, and so on. I know
that in Conidtional Formatting, you can do up to three, but I have ten.

I wrote some code below but it only colors the ID field on the form portion,
and I want it to color it on the datasheet portion in the split form as well.
The Conditional Formatting will color both, so I figured there was a way to
edit this code to color both the form and datasheet portion. Or better yet,
I prefer using a Datasheet form rather than a split form if there is a way.

Here is my code thus far (the colors aren't really accurate):

Private Sub Form_Current()
Dim sColor_Codes As Variant 'To account for null values
sColor_Codes = Me.Color_Codes

Select Case sColor_Codes
Case "Paying"
Me.ID.BackColor = RGB(0, 0, 255)
Case "Restructure"
Me.ID.BackColor = RGB(0, 255, 0)
Case "Follow-Up"
Me.ID.BackColor = RGB(255, 0, 0)
Case Else
Me.ID.BackColor = RGB(125, 125, 125)
End Select

End Sub


Thanks a lot!
 
D

Dorian

This may not be a good idea!
You do understand that users may switch their color schemes via the Control
Panel, so to be in compliance with this your forms should use ONLY Windows
default colors.
I'm not sure why you need to do this but I'm sure there is a better solution.

-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".
 
Z

zmenloans

Dorian,

Thank you for your response. I need to do the conditional formatting for
the staff that will actually use it. Each choice in the combo box relates to
a certain color that they are all used to seeing, and so they wanted to see
it in the datasheet part of the split form. They will not be changing any
colors; they just hope that the colors change when they choose the certain
item from the combo box. I hope I am making sense (I'm pretty new at all
this stuff). Basically, I want to know how to do conditional formatting for
more than 3 items in a split form so that it shows up on both the form and
datasheet part of the split form.

Thanks!
 

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