I'm trying to make a field on a report highlight in red with white bold font on a report when it has an "S" populated. This keeps making all records in the field red. Please help!
Private Sub Report_Activate()
If Me![PULL STATUS] = "S" Then
Me![PULL STATUS].BackColor = vbRed
Me![PULL STATUS].FontBold = True
Me![PULL STATUS].ForeColor = vbWhite
End If
End Sub
MS Access uses Conditional Formatting - much like MS Excel; I recommend this instead of using VBA to change the backcolor pragmatically. This should work well for 'Continuous Forms.'
The code you have should be contained in the On Format event of the Detail section of the report. When you set the
BackColor
,FontBold
, andForeColor
it stays that way until it is changed again.So what you need is an else statement to perform the opposite if not true. Something like: