Change Report Line Color

  • Thread starter Thread starter Daniel
  • Start date Start date
D

Daniel

Hello All,

I have searched for this answer, but have only found how to change the color
for a single text box.

I have a vehicle report that my company uses. I am needing to color code
the records in the report depending on the make of the vehicle; Ford, Dodge,
etc. I have looked under conditional formatting, but that seems to only
change the color for that text box depending on the value of that text box.
Can anyone help me please.

Thanks,

Daniel
 
Daniel said:
I have a vehicle report that my company uses. I am needing to color code
the records in the report depending on the make of the vehicle; Ford, Dodge,
etc. I have looked under conditional formatting, but that seems to only
change the color for that text box depending on the value of that text box.


Changing the ForeColor must be done for each text box.

OTOH, You can make all the text box's BackStyle transparent
and just set the detail section's BackColor property.
 
I do not know how to do this with Conditional Formatting, which seems very
limited. I would create empty labels, fill each with a color for the related
auto, then Format\Send it Back, so they all sit behind the text. I would
make these labels invisible by default. Then I would create an OnFormat
event which checks the automobile field and, with a simple Select Case
module, I would toggle the Visible condition of the appropriate colored label.

It might look like this:

Select Case Me.CarType
Case "Ford"
Me.RedLabel.Visible = True
Case "Fiat"
Me.BlueLabel.Visible = True
Case "Citroen"
Me.GreenLabel.Visible = True
Case "Chevrolet"
Me.YellowLabel.Visible = True
End Select
 
You can use code in the On Format event of the report section that loops
through the controls in the section and changes the forecolor based on the
value of another control.
 
I'm *very* new at this, but had to figure it out yesterday ... Here's some
code that worked for me. Changes the color and visibility of several name
and address fields based on the value of the field [txtcategory].

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

' Formats the text fields so that the categories "Members" and "Amb Member
- Added"
' are bold and in red. Category field is invisible.

Debug.Print "Name: " & txtFileAs & " Category: " & txtCategory
If txtCategory = "Ambassador Member" Or txtCategory = "Amb Member -
Added" Then
Me.txtFileAs.FontBold = True
Me.txtBusinessAddressStreet1.FontBold = True
Me.txtBusinessAddressCity.FontBold = True
Me.txtBusinessAddressState.FontBold = True
Me.txtBusinessAddressPostalCode.FontBold = True
Me.txtEmailAddress.FontBold = True
Me.txtCompanyName.FontBold = True
Me.txtBusinessTelephoneNumber.FontBold = True

Me.txtFileAs.ForeColor = 255
Me.txtBusinessAddressStreet1.ForeColor = 255
Me.txtBusinessAddressCity.ForeColor = 255
Me.txtBusinessAddressState.ForeColor = 255
Me.txtBusinessAddressPostalCode.ForeColor = 255
Me.txtEmailAddress.ForeColor = 255
Me.txtCompanyName.ForeColor = 255
Me.txtBusinessTelephoneNumber.ForeColor = 255

Else
Me.txtFileAs.FontBold = False
Me.txtBusinessAddressStreet1.FontBold = False
Me.txtBusinessAddressCity.FontBold = False
Me.txtBusinessAddressState.FontBold = False
Me.txtBusinessAddressPostalCode.FontBold = False
Me.txtEmailAddress.FontBold = False
Me.txtCompanyName.FontBold = False
Me.txtBusinessTelephoneNumber.FontBold = False

Me.txtFileAs.ForeColor = 8388608
Me.txtBusinessAddressStreet1.ForeColor = 8388608
Me.txtBusinessAddressCity.ForeColor = 8388608
Me.txtBusinessAddressState.ForeColor = 8388608
Me.txtBusinessAddressPostalCode.ForeColor = 8388608
Me.txtEmailAddress.ForeColor = 8388608
Me.txtCompanyName.ForeColor = 8388608
Me.txtBusinessTelephoneNumber.ForeColor = 8388608

End If

End Sub
 
Back
Top