Conditional Formatting

cbearden

Registered User.
Local time
Today, 14:38
Joined
May 12, 2004
Messages
84
I am trying to use conditional formatting in my report but I am having trouble.

I am trying to get these fields to be bold:

txtName
curGcost
curGrefund
curSCcost
curSCrefund

The condition is:

Expression Is [chkDealerVisit] = True


When I view my report, it comes up with the appropriate records bolded BUT the txtName field is showing "#NAME". If I leave the conditional formatting off, the txtName shows up.

Could someone help?

Thanks
 
I am new to this stuff, but when I have received "#NAME" in a text box it is because The reference to the field that populates the textbox was either spelled incorrectly or I put in the wrong field that was not in the Record Source for the Report/Form.

Hope this helps.
 
Copy This to your Report's Code

Code:
Option Compare Database

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me.chkDealerVisit = True Then
    ' Change Background Color to Yellow (I think)
    Detail.BackColor = "11599871"
    ' Change Font to Bold for all Controls in Section
    For Each CtlDetail In Me.Detail.Controls
        With CtlDetail
            .FontWeight = 900
        End With
    Next
Else
    ' Change Background Color to White
    Detail.BackColor = vbWhite
    ' Change Font to Normal for all controls in section
    For Each CtlDetail In Me.Detail.Controls
        With CtlDetail
            .FontWeight = 400
        End With
    Next
End If

 End Sub

'To change on specific controls

If Me.chkDealerVisit = True
    ' Change Font to Bold for these Controls in Section
            Me.txtName.FontWeight = 900
            Me.curGcost.FontWeight = 900
            Me.curGrefund.FontWeight = 900
            Me.curSCcost.FontWeight = 900
            Me.curSCrefund.FontWeight = 900
Else
     ' Change Font to Normal for these Controls in Section
            Me.txtName.FontWeight = 400
            Me.curGcost.FontWeight = 400
            Me.curGrefund.FontWeight = 400
            Me.curSCcost.FontWeight = 400
            Me.curSCrefund.FontWeight = 400
End if

This is courtesy of other posters on the board who enlightened me.

hope this helps.

sportsguy
 
Last edited:
Cbarden

I have used this method in the OnFormat/Detail section of some reports and it works well and is simple;

If Me!YourField YourCodeThen
Me! YourField.FontBold = True
Else
Me! YourField.FontBold = False
End If
End sub


You can also use it to set visibility and color
 
Last edited:

Users who are viewing this thread

Back
Top Bottom