Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing the backcolor of a field in a report 1

Status
Not open for further replies.

redaccess

MIS
Aug 2, 2001
110
US
Is there a way to change the backcolor of a field in a report based on that fields' value?
 
I took this partial VBA code from the help example for backcolor:

lngYellow = RGB(255, 255, 0)
lngWhite = RGB(255, 255, 255)
If curAmntDue > 100 Then
Me!txtPastDue.BackColor = lngYellow
Else
Me!txtPastDue.BackColor = lngWhite
End If
 
That code is for a Form_Current event for a Form. I'm looking to change backcolor in a Report. I don't think that code will work.
 
OK, in the reports detail on_format event:

If [fld_division] = "304" Then
Reports("rpt_NameOfReprot")("Textboxname").BackColor = vbRed
Else
Reports("rpt_NameOfReport")("Textboxname").BackColor = vbYellow
End If
 
I need to add that the Back Style must not be transparent.
 
OK, I tweaked it a little (assume 304 is division you want to highlight) - this example is in the on format event of the detail section:

If [fld_division] = "304" Then
Reports("rpt_ReportName")("txtbox_Name").BackStyle = 1
Reports("rpt_ReportName")("txtbox_Name").BackColor = vbRed
Else
Reports("rptReportName")("txtbox_Name").BackStyle = 0
'since backstyle is now transparent,
'the next line isn't really necessary but sets it back to a "default"
Reports("rptReportName")("txtbox_Name").BackColor = vbWhite
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top