HELP!: VBA code for Datasheet Form for background colors

Z

zmenloans

I have a datasheet form and I want a field (or better yet, an entire row) to
change colors depending on a choice from a Combo Box. It does this using
the conditional formatting option but I need it for more than three
conditions. I was able to edit code like this so that the ID box would change
colors depending on how I input the Combo Box value(my column is called
Color_Codes):

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

However, it doesn't work. The color changes in Design View but not in
Datasheet view. I tried using a split form also and it only changes colors
on the top form part, and not the bottom datasheet part, which I really need
it for.

Any help would be appreciated. Please include detailed directions on where
to edit or put the code, because I am kind of new at this stuff.

Thanks a lot!
 

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