Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2004
    Posts
    41

    Post Unanswered: Report - Changing text color

    I have a field in the Detail line that I would like to make red if it doesn't match a field in the Header line. Is this possible?

    For example:

    Ship from: Here <- field to match

    Date Item# CurrentLocation
    Today XXXX NotHere <- field should appear in red
    Today YYYY Here <- field should remain black

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Use the OnPrint event of the detail section to set your colors.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  3. #3
    Join Date
    Mar 2004
    Posts
    41
    Is there any way to do this without printing? The reports are typically viewed rather than printed.

  4. #4
    Join Date
    Apr 2004
    Location
    outside the rim
    Posts
    1,011
    One trick is to hide the data field and use two overlapping unbound controls. One control is normal font properties, the other is your "stand out" - red, bold, etc.

    Make the recordsource of the "Stand out" field:
    =Iif([FieldInHeader] <> [FieldInDetail],[FieldInDetail],"")


    Make the recordsource of the normal field:
    =Iif([FieldInHeader] = [FieldInDetail],[FieldInDetail],"")


    Make sure the bound data field is hidden.

    This works both on screen and in print. I like to use this for a "NO DATA!" tag in a field that's missing it's data when printing reports. To use a message instead of the field value, simply place text in quotes as the second argument in the function.

    Have fun!
    have fun!

    Todd S.
    click to email


    Independent Development Consultant
    Biz db & reports - SQL, Access, Crystal, Seradex and more
    Small, custom, unique programs - Office, VBA, .NET


    _________________________________________________
    Favorite message from Windows:
    There was an error displaying the previous error message

    Sadly, there was no error number to look up ...

  5. #5
    Join Date
    Jun 2002
    Location
    Saudi Arabia / Philippines
    Posts
    126
    Hi

    I'm not used to doing this in reports but I do similar things in many forms. Read up on FormatConditions, I think these work for reports as well as forms.

  6. #6
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1

    Post

    Do it the Format event of your DetailArea of your Report

    PHP Code:
      Private Sub DetailArea_Format(Cancel As IntegerFormatCount As Integer)
        If 
    DB_Name "Hss.mdb" Then
            DB_Name
    .ForeColor vbBlue
        
    ElseIf DB_Name "Pbh.mdb" Then 
           DB_Name
    .ForeColor vbRed
        
    Else
           
    DB_Name.ForeColor vbBlack
        End 
    If
      
    End Sub 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •