Conditional Formating a Textbox in report...

C

chemicals

I have a report that I want to change any empty fields (textboxes) to have a
red background. I cannot seem to get backgound colors to work?

If I set conditional formatting on a value < 10 with text color changing it
seems to work.

Here's my 2 attempts:

Len([NumberOfReps])<1 Or IsNull([NumberOfReps]) ---set background to red

Then I tried this in the OnFormat event of the Detail section:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Not Len(Me.NumberofReps) >= 1 Then
Me.NumberofReps.BackColor = vbRed
End If
End Sub

Background colors don't seem to change???
 
C

chemicals

Never mind!!!

I had the textbox properties for BackStyle as Transparent instead of
Normal......Duh!
 
A

Allen Browne

Assuming this is Access 2000 or later, you don't need any code. Just use
Conditional Formatting.

1. In report design view, select the NumberOfReps text box.

2. Choose Conditional Formatting on the Format menu.

3. Set Condition 1 to:
Expression: [NumberOfReps] Is Null
and choose the color in the bucket.
 

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