Ask Experts Questions for FREE Help !
Ask
    erosinski's Avatar
    erosinski Posts: 12, Reputation: 1
    New Member
     
    #1

    Oct 5, 2005, 11:00 AM
    changing detail's color in reports
    I need to change the color of a row in the details if a certain field contains a certain text. Ex: field status =shipped so make the row green, status = packed make the row red etc. conditional formatting will only change the one field. If anyone has any ideas let me know
    erosinski's Avatar
    erosinski Posts: 12, Reputation: 1
    New Member
     
    #2

    Oct 5, 2005, 11:39 AM
    never mind, figured it out. Here's the solution in case someone needs it someday.

    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    If [status] = "Needs Packed" Then 'status is the field it is checking for a value
    status.ForeColor = RGB(255, 0, 0) 'rgb(,, ) is the red, green blue values of colors
    antshipdate.ForeColor = RGB(255, 0, 0)
    sorder.ForeColor = RGB(255, 0, 0)
    smfgnum.ForeColor = RGB(255, 0, 0) 'these are all the fields you change colors of
    companyname.ForeColor = RGB(255, 0, 0)
    prodno.ForeColor = RGB(255, 0, 0)
    shipqty.ForeColor = RGB(255, 0, 0)

    End If
    end sub
    ScottGem's Avatar
    ScottGem Posts: 64,966, Reputation: 6056
    Computer Expert and Renaissance Man
     
    #3

    Oct 6, 2005, 05:58 AM
    A few points here.

    First, when asking how to do something with software it would help if you gave the software name and version. There was no way for anyone to answer based on your first post since you didn't mention the platform.

    Second, It appears you are using Microsoft Access from your second post. However, your code is not complete. You should provide an Else clause to format the controls if the condition is not met. Also while RGB function you used will work, there are other ways as well. If you are using a primary color you could just use:

    controlname.Forecolor=Green or Red

    If you want a more specific color, format the control, then look at the number listed in the Property dialog, then use that number.

    Finally, I've done this a different way. Rather then change each control, what I've done is put a box object behind all the controls. I've then made the BackStyle of the controls as transparent. Then all I do is change the backcolor of the box depending on the fields value. This highlights the row more clearly (especially if you aren't using a color printer).
    erosinski's Avatar
    erosinski Posts: 12, Reputation: 1
    New Member
     
    #4

    Oct 6, 2005, 06:17 AM
    I wrote this in a hurry, I use rgb because I played with opengl too much, and I did use a box at first but my boss is very stingy with the amount of toner we use. I did use an else, but only posted code for the block I was having problems with. If I had more than 3 "status" then I would have used case and not if statements. And you are right about the platform issue, I am members of a few forums and the others are strictly access 2003
    ScottGem's Avatar
    ScottGem Posts: 64,966, Reputation: 6056
    Computer Expert and Renaissance Man
     
    #5

    Oct 6, 2005, 09:37 AM
    No problem I was just making some suggestions and pointing out some issues to others who might try your solution.

    One point on the toner issue. You can change the background of the controls to Normal, so the whole row won't have the colored background. But, in my opinion, using a box whill make the highlight morer apparent.

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

Need name of older movie [ 2 Answers ]

It most probably was on television late 70's early 80's. There was a woman who cured the sick by touching them. I remember one scene in which she stopped a little girl's nosebleed. I know it's not much, please help if you can. Thanks!!

MS Access Reports [ 4 Answers ]

Hello all, I need to make a report on access and I need a count of records, that will need to satisfy 2 conditions. For example: records should be counted if the on the Sex column is "M" and the rating column is "2". Any ideas? This is very easy if you filter the records on a table,...


View more questions Search