Conditional Formatting in Reports

D

David

Hello,

I am trying to set conditional formatting for all fields
that I am going to use in a report. I would like all
blank fields to print with a grey background on my
report. How do I set up my conditional format to get this
result? Any information would be greatly appreciated.

Thank you,
David
 
F

Fredg

David,
If you have lots of them...
To do all of them you don't need the control's Conditional Format property.

Code the Report's Detail Format event:

Dim C As Control
For Each C In Controls
If TypeOf C Is TextBox Then
If IsNull(C) Then
C.BackColor = 12632256 ' gray
Else
C.BackColor = vbWhite
End If
End If
Next

Also, if there were a few you didn't want changed,
you can exclude them.

Dim C As Control
For Each C In Controls
If TypeOf C Is TextBox Then
If C.Name = "City" Then
ElseIf IsNull(C) Then
C.BackColor = 12632256 ' gray
Else
C.BackColor = vbWhite
End If
End If
Next

To do just a few selected ones, then Conditional Formatting will do fine.
Select the control to be conditionally formatted.
Format + Conditional Formatting
Click on the Condition 1 drop-down box.
Select:
Expression Is
Write in the text box alongside the drop-down:
IsNull([ControlName])
Set the color as wanted.
Exit the dialog.

Do this for each additional control.
 

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