Results 1 to 10 of 10
  1. #1
    Join Date
    Mar 2009
    Posts
    120

    Unanswered: Highlight a Control

    Hi Everyone,

    I was wondering. Is it possible to have a Date Field on a Report, highlight in a different color, not the text but the whole field, based on the date.

    So if the Date in the field is past, highlight in Yellow.

    If the Date is In the future, but in the current calendar year, highlight in Green.

    If the date is in the next year or subsequent years highlight in Blue.
    Attached Files Attached Files
    Last edited by CHI Brian; 06-27-14 at 09:59. Reason: add attachment

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    use conditional formatting and set the controls background color
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Mar 2009
    Posts
    120
    THank you healdem. I found the conditional formating however, I am having trouble with how to put it in there.

    Do I use "Field Value is" or "Expression Is" and regarless of which one, how do I type in what I want. So the date is less than today. What is the expression? I tried using

    Field Is - Less than - Date(), but it didn't like that.

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    TBH I don't know off hand, I so rarely use conditional formatting. I tend to prefer to explcitily set these sort of things in the report or controls on format event

    so will will need to either read the helpfile or search for a worked example

    datediff("d",[columnname],date()) > 0
    'the date is in the future

    datediff("d",[columnname],date()) < 0
    the date is in the past

    datediff("d",[columnname],date()) = 0
    its todays date

    datediff("y",[columnname],date()) = 0
    is this year

    datediff("y",[columnname],date()) > 0
    is next year or more

    datediff("y",[columnname],date()) < 0
    is last year or older

    A problem I can forsee is if your year is an accounting year then you need to find a mechanism to translate accounting years into real dates
    I'd rather be riding on the Tiger 800 or the Norton

  5. #5
    Join Date
    Mar 2009
    Posts
    120
    thanks healdem. I understand the formulas you wrote however, how do I get them to put the color in based on that formula?

    When you say the format property, do you mean the one that is just under Control Source when you open the Properties tab for the control?

    Sorry for all the questions but I am only as good as myself and what I've learned.

  6. #6
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    As I said before I don't use conditional formatting so I can't rememebr how you specify what in CF. Persoanlly I tend to use code inside the report detail or control on format event for this sort ofthing. WHy?
    well you can see what is being set in code (no hunting around trying to workout whats happening
    you are not limited by CF, you cna have as many formatting rules as you like, you can set what properties you like
    its easier to debug, you can put breakpoint on it
    you can define the formatting rules in a table so if a new user decides they want to muck about with the colours they can do to their hearts content with no further developer resource required

    IIRC conditional formatting allows 3 or is it 4 rules, each of which can set a specific formatting setup. the rule definiton evaluatesw to true or false, if true then the sepcified formatting is applied

    how you define what is the correct way of defining the rule.. I dunno, RTFM or google it.
    likewise how you define the formatting. from what I remember its pretty straightforward, the dialog talks you through the various steps

    Im trying to think back last time I used CF, think is was about 2006 or perhaps 2007, and I don't mean 7 minutes past 8 last night
    I'd rather be riding on the Tiger 800 or the Norton

  7. #7
    Join Date
    Mar 2009
    Posts
    120
    Okay. I know what you are saying and I understand all that. My last questinos related to your date formulas and where to put them and how to get the field to color in the specific color.

    datediff("y",[columnname],date()) > 0
    is next year or more

    How would I get this formula to highlight the contorl in BLUE. And would i put it in the Format Property on teh Field Properties tab just under Control Source?

  8. #8
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    I dont know
    I dont use conditional formatting
    cf should be able to handle this for you

    I forget how you open up cf... the help manual should be able to tell you.

    once you open up the cf dialogue you can define whatever rules you need. But I cant tell you how to do so as i cannot remember how to use cf.

    what I do know us that has nothing to do with the properties of a control exposed in the repirt designer. Cf will be visible in one if the menu bar items.. possibly tools, possibly something else. If you cannot find out how to apply cf vua google or help then you will need to go through each menu option till you find cf.
    I'd rather be riding on the Tiger 800 or the Norton

  9. #9
    Join Date
    Mar 2009
    Posts
    120
    Okay. I get what you are saying. The formulas you typed I could use in the CF, not in what you said about typing in the Format property.

  10. #10
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    An alternative approach is to place code in the report or controls on format EVENT. Thats my oreference for these sort of issues
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

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