Back Color

  • Thread starter Thread starter Ryan
  • Start date Start date
R

Ryan

I don't know if this is possible or not but I was
wondering if I could change the back color of a textbox on
a report based on the value that it returns. If this is
possible can someone please tell me how? I know how to do
it in forms but can't figure what to do to accompliosh
this with a report.

Thanks,
Ryan
 
Ryan said:
I don't know if this is possible or not but I was
wondering if I could change the back color of a textbox on
a report based on the value that it returns. If this is
possible can someone please tell me how? I know how to do
it in forms but can't figure what to do to accompliosh
this with a report.


You should be able to do this the same way you did it in a
simple form. What have you tried and what about it isn't
working?
 
I tried to call the textbox on the On_Open Event of the
report but it didn't recognize it. The code I used was:

If txtDate > Date() Then
txtDate.BackColor = vbblue
End If

I get an error saying that I entered an expression that
has no value. What am I doing wrong?

Ryan
 
Ryan said:
I tried to call the textbox on the On_Open Event of the
report but it didn't recognize it. The code I used was:

If txtDate > Date() Then
txtDate.BackColor = vbblue
End If

I get an error saying that I entered an expression that
has no value. What am I doing wrong?

You didn't use the Open event in a form either. That's just
too soon for control values to be available. In a Form you
would normally use the Current event, in a report, use the
Format event of the section containing the text box.
--
Marsh
MVP [MS Access]



 
I tried to call the textbox on the On_Open Event of the
report but it didn't recognize it. The code I used was:

If txtDate > Date() Then
txtDate.BackColor = vbblue
End If

I get an error saying that I entered an expression that
has no value. What am I doing wrong?

Ryan

Place the code in the Format event of whatever section the control is
in. i.e. if the control is in the Detail Section use the Detail Format
event.

Also if you change the backcolor of the control when the condition is
met, you also must change it back when the condition is not met.
And... in VBA you do not need the () around certain function, such as
Date, Now, Time, etc.

If txtDate > Date Then
txtDate.BackColor = vbblue
Else
txtDate.BackColor = vbBlack
End If
 
Back
Top