Results 1 to 15 of 15

Thread: Report Coloring

  1. #1
    Join Date
    May 2005
    Posts
    1,191

    Unanswered: Report Coloring

    Is there a way to color the detail section of a report different colors for different records, depending on a certain criteria? For example, if a boolean field is checked yes, color that record of the report vbyellow.

    Thanks for any help in advance.
    Me.Geek = True

  2. #2
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Formatting ... In the detail section ...Set the backcolor to yellow ...
    Back to Access ... ADO is not the way to go for speed ...

  3. #3
    Join Date
    May 2005
    Posts
    1,191
    Thanks for that Mike

    What I meant was, that some fields get colored white and some get yellow, depending on certain criteria.

    After searching online some more I think I might be able to use this example, with a little customization.

    Thanks.
    Me.Geek = True

  4. #4
    Join Date
    May 2005
    Posts
    1,191
    Ok, so this is the code I've been trying out on the OnFormat event. I decided just to paint a textbox instead of the whole detail section.
    PHP Code:
    White 16777215
    Blue 
    16756059
    Green 
    8454016
    Yellow 
    8454143
    Red 
    8251258

    Dim Difference 
    As Long
    Date_Difference 
    DateDiff("d"Me!TxtBoxDateEnteredDate)

    If 
    Date_Difference >= And Date_Difference 30 Then
        Me
    !ShadingBox.BackColor Blue
    ElseIf Date_Difference >= 30 And Date_Difference 60 Then
        Me
    !ShadingBox.BackColor Green
    ElseIf Date_Difference >= 60 And Date_Difference 120 Then
        Me
    !ShadingBox.BackColor Yellow
    ElseIf Date_Difference >= 120 Then
        Me
    !ShadingBox.BackColor Red
    Else
        
    Me!ShadingBox.BackColor White
    End 
    If 
    Looking at the attachment, any idea why this works sometimes and not others? For example, one of the records is over 2 years old (1854), but it's painted green.

    Thanks again for any help
    Attached Thumbnails Attached Thumbnails Coloring.JPG  
    Me.Geek = True

  5. #5
    Join Date
    May 2005
    Posts
    1,191
    Not sure how it happened, but the color for red was wrong.

    This works:
    PHP Code:
    White 16777215
    Blue 
    16756059
    Green 
    8454016
    Yellow 
    8454143
    Red 
    8421631

    Dim Difference 
    As Long
    Date_Difference 
    DateDiff("d"Me!TxtBoxDateEnteredDate)

    If 
    Date_Difference >= And Date_Difference 30 Then
        Me
    !ShadingBox.BackColor Blue
    ElseIf Date_Difference >= 30 And Date_Difference 60 Then
        Me
    !ShadingBox.BackColor Green
    ElseIf Date_Difference >= 60 And Date_Difference 120 Then
        Me
    !ShadingBox.BackColor Yellow
    ElseIf Date_Difference >= 120 Then
        Me
    !ShadingBox.BackColor Red
    Else
        
    Me!ShadingBox.BackColor White
    End 
    If 
    Me.Geek = True

  6. #6
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Nicky my boy, you got a larger problem than that ... MOST of your colors are wrong ... Try putting a breakpoint on you difference call and make sure it's calc'ing correctly ...
    Back to Access ... ADO is not the way to go for speed ...

  7. #7
    Join Date
    May 2005
    Posts
    1,191
    Quote Originally Posted by M Owen
    Nicky my boy, you got a larger problem than that ... MOST of your colors are wrong ... Try putting a breakpoint on you difference call and make sure it's calc'ing correctly ...
    No, this method does work. I added a box to each record to spit out the Date_Difference using the code below, you can see the results in the attached picture.
    PHP Code:
    Dim Difference As Long
    Date_Difference 
    DateDiff("d"Me!TxtBoxDateEnteredDate)
    Me.TxtBoxDateDiff Date_Difference

    If Date_Difference >= And Date_Difference 30 Then
        Me
    !ShadingBox.BackColor Blue
    ElseIf Date_Difference >= 30 And Date_Difference 60 Then
        Me
    !ShadingBox.BackColor Green
    ElseIf Date_Difference >= 60 And Date_Difference 120 Then
        Me
    !ShadingBox.BackColor Yellow
    ElseIf Date_Difference >= 120 Then
        Me
    !ShadingBox.BackColor Red
    Else
        
    Me!ShadingBox.BackColor White
    End 
    If 
    It works
    Attached Thumbnails Attached Thumbnails colored.JPG  
    Me.Geek = True

  8. #8
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Quote Originally Posted by nckdryr
    Not sure how it happened, but the color for red was wrong.

    .all the more reason to use VBA's intrinsic constants in my view
    I'd rather be riding on the Tiger 800 or the Norton

  9. #9
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    A tiddly coding preference of mine - saves on typing and makes (IMO) it easier to read:
    Code:
    
    If Date_Difference >= 0 And Date_Difference < 30 Then 
        Me!ShadingBox.BackColor = Blue 
    ElseIf Date_Difference < 60 Then 
        Me!ShadingBox.BackColor = Green 
    ElseIf Date_Difference < 120 Then 
        Me!ShadingBox.BackColor = Yellow 
    ElseIf Date_Difference >= 120 Then 
        Me!ShadingBox.BackColor = Red 
    Else 
        Me!ShadingBox.BackColor = White 
    End If
    The ">= 30" bit is unnecessary as it is handled in the previous condition etc..

    Not germain to the problem though
    Testimonial:
    pootle flump
    ur codings are working excelent.

  10. #10
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    441
    Or Select Case
    Code:
    Select Case Date_Difference
        Case Is < 0
            Me!ShadingBox.BackColor = White 
        Case Is < 30
            Me!ShadingBox.BackColor = Blue
        Case Is < 60
            Me!ShadingBox.BackColor = Green 
        Case Is < 120
            Me!ShadingBox.BackColor = Yellow 
        Case Else
            Me!ShadingBox.BackColor = Red 
    End Select
    Roy-Vidar

  11. #11
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by RoyVidar
    Or Select Case
    Agreed - I prefer that too but decided against stating that particular preference. Now - I am sure you noticed that your solution will yield different results to Nick
    Testimonial:
    pootle flump
    ur codings are working excelent.

  12. #12
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    441
    pootle_flump,
    I'm sorry, but I don't see that. However, I do see that yours differ from nckdryr and mine, in that when there's a negative datediff, it becomes green. Check out your first Else If.
    Roy-Vidar

  13. #13
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    My apologies Roy. No doubt not for the last time I resolve never again to post whilst drunk
    Testimonial:
    pootle flump
    ur codings are working excelent.

  14. #14
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Quote Originally Posted by pootle flump
    My apologies Roy. No doubt not for the last time I resolve never again to post whilst drunk

    for shame
    denying your British culture and traditions
    I'd rather be riding on the Tiger 800 or the Norton

  15. #15
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by healdem
    for shame
    denying your British culture and traditions
    Well.... I am a teensy bit drunk now
    Testimonial:
    pootle flump
    ur codings are working excelent.

Posting Permissions

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