Changing Back Color for individual fields in report using VBA?

S

sgmurray

I am trying to dynamically change the BackColor value for individual fields
in a report. So far I haven't come up with the right code. Help !?!
 
T

tina

try adding code to the report section's Format event to read the value in
the control(s) and set the control BackColor accordingly. for instance, if
your control is in the report's Detail section, try something along the
lines of

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

Select Case Me!MyControl
Case "something"
Me!MyControl.BackColor = 111
Case "something else"
Me!MyControl.BackColor = 237
Case Else
Me!MyControl.BackColor = 555
End Select

End Sub

the above assumes that "MyControl" has a Text data type. see the Select Case
topic in Help if you're not familiar with it.

hth
 
B

Bisro Solan

This is exactly what I want for one of my reports, but I am too much of a
beginner to understand where to put this code to get it to work for my
application. Can someone help with a less technical hand?
 
L

len

You could place your function's code within the report's code module using
the on-open event or on-print event to change the background color.
 
Top