changing color based on values

Ask a Question related to FileMaker, Design and Development.

  1. #1

    Default changing color based on values

    I'm trying to change the color of a field based on it's value. For
    example we do running races and assign age groups to participants.
    AGE GROUP is M20-29 the text is red, M30-39 blue.

    Any direction would be appreciated.
    Trail Runner Guest

  2. Similar Questions and Discussions

    1. Style changes based upon Data Values
      I want to change the style of a data presented based upon the value of the data. For example, I if the value is positive I want it to appear black...
    2. Changing hyperlink template based on data contents
      I'm pretty new to all of this, so please forgive me if this is a question you've heard too many times. I'm using VS2003 and vb.net in the...
    3. Changing row backcolor based on a column value from dataset
      I have a asp vb.net webform that uses a dataset to bind from a mssql backend via a stored proc and displays its results in a datagrid. In one of...
    4. Changing button's URLs based upon text field
      I have created a quiz using the Coursebuilder extensions in DWMX, which puts their score in a text field on the page (no data base is used). What I...
    5. Selecting records based on multiple values
      I'm trying to select records which have a FIELD_VALUE = x, y, or z. I've tried several things and I can't seem to make it work correctly. Here is...
  3. #2

    Default Re: changing color based on values

    In article <cf008b05.0309292054.1470393f@posting.google.com >,
    [email]eric@redwoodtrails.com[/email] (Trail Runner) wrote:
    > I'm trying to change the color of a field based on it's value. For
    > example we do running races and assign age groups to participants.
    > AGE GROUP is M20-29 the text is red, M30-39 blue.
    >
    > Any direction would be appreciated.

    The short answer is: You can't.

    There's no way to change the colour of the text in a field based on
    it's value (except number fields when they're negative).



    The long answer depends on which you prefer. You can either SEEM to
    change the colour of the text OR simply change the colour of a graphic
    in a container field behind the text.

    The graphic method is easier in some ways (especially if you have to
    change the age group ranges at some stage), but since you wanted to
    change the text's colour, one way to make it LOOK like it does this is
    to use separate calculated fields for each age group (and within that
    Male and Female?), eg.

    AgeGroupM2029 = If(Gender = "M" and Age > 19 and Age < 30,
    "M20-29", "")

    AgeGroupM3039 = If(Gender = "M" and Age > 29 and Age < 40,
    "M30-39", "")

    etc.

    Put these new fields on your layout and format each with the
    appropriate text colour and make sure they have a transparent fill
    colour. Then stack all fields in a small pile one on top of the other.

    Now when the data is entered into the Gender and Age fields the
    appropriate AgeGroup field will automatically calculate and the others
    will be blank. Since these fields are all in a pile you only see what
    looks like one field of the correct colour and text. :o)


    BUT there's one problem: it's not possible to easily perform Finds on
    the "Age Group" since it's now made up of multiple fields.

    There are various ways around this if you need to be able to do such
    Finds. Probably the easiest is to create another Age Group calculation
    field, eg.

    AgeGroup = AgeGroupM2029 & AgeGroupM3039 & ...

    Hide this new field at the bottom of the pile (make the previously
    lowest field non-transparent). Now format the top field as a button
    which runs a script that simply says:

    Go To Field [AgeGroup]

    Now when anyone clicks onto the Age Group stack of fields, the script
    puts them into the combined Age Group field - perfect for performing
    Finds and since it's a claculation field they can't make changes if
    they click on it when in Browse mode.

    This AgeGroup field can also be used for black and white printouts and
    other calculations or scripts rather than needing to plow through the
    pile of separate ones each time. :o)



    Helpful Harry
    "Just trying to help whenever I can." :o)
    Helpful Harry Guest

  4. #3

    Default Re: changing color based on values

    Huh? Why not just one calc, returning a container, planted underneath the
    data entry field? First, create some global containers and fill them with
    rectangles colored appropriately. Then:

    Case(
    TextToNum(Age Group) > 19 and TextToNum(Age Group) < 30,
    Container_Red,

    TextToNum(Age Group) > 29 and TextToNum(Age Group) < 40,
    Container_Blue
    )

    ....etc. If the pattern persists, you could also use Choose().

    If you set that to not allow entry (or backwards-- I always get this one
    confused), a cursor placed in the overlying field should work on that field,
    for searches and entry. Set the calc propeties to expand and not maintain
    proportions.

    --
    John Weinshel
    Datagrace
    Vashon Island, WA
    (206) 463-1634
    Associate Member, Filemaker Solutions Alliance


    "Helpful Harry" <helpful_harry@nom.de.plume.com> wrote in message
    news:300920031855295725%helpful_harry@nom.de.plume .com...
    > In article <cf008b05.0309292054.1470393f@posting.google.com >,
    > [email]eric@redwoodtrails.com[/email] (Trail Runner) wrote:
    >
    > > I'm trying to change the color of a field based on it's value. For
    > > example we do running races and assign age groups to participants.
    > > AGE GROUP is M20-29 the text is red, M30-39 blue.
    > >
    > > Any direction would be appreciated.
    >
    >
    > The short answer is: You can't.
    >
    > There's no way to change the colour of the text in a field based on
    > it's value (except number fields when they're negative).
    >
    >
    >
    > The long answer depends on which you prefer. You can either SEEM to
    > change the colour of the text OR simply change the colour of a graphic
    > in a container field behind the text.
    >
    > The graphic method is easier in some ways (especially if you have to
    > change the age group ranges at some stage), but since you wanted to
    > change the text's colour, one way to make it LOOK like it does this is
    > to use separate calculated fields for each age group (and within that
    > Male and Female?), eg.
    >
    > AgeGroupM2029 = If(Gender = "M" and Age > 19 and Age < 30,
    > "M20-29", "")
    >
    > AgeGroupM3039 = If(Gender = "M" and Age > 29 and Age < 40,
    > "M30-39", "")
    >
    > etc.
    >
    > Put these new fields on your layout and format each with the
    > appropriate text colour and make sure they have a transparent fill
    > colour. Then stack all fields in a small pile one on top of the other.
    >
    > Now when the data is entered into the Gender and Age fields the
    > appropriate AgeGroup field will automatically calculate and the others
    > will be blank. Since these fields are all in a pile you only see what
    > looks like one field of the correct colour and text. :o)
    >
    >
    > BUT there's one problem: it's not possible to easily perform Finds on
    > the "Age Group" since it's now made up of multiple fields.
    >
    > There are various ways around this if you need to be able to do such
    > Finds. Probably the easiest is to create another Age Group calculation
    > field, eg.
    >
    > AgeGroup = AgeGroupM2029 & AgeGroupM3039 & ...
    >
    > Hide this new field at the bottom of the pile (make the previously
    > lowest field non-transparent). Now format the top field as a button
    > which runs a script that simply says:
    >
    > Go To Field [AgeGroup]
    >
    > Now when anyone clicks onto the Age Group stack of fields, the script
    > puts them into the combined Age Group field - perfect for performing
    > Finds and since it's a claculation field they can't make changes if
    > they click on it when in Browse mode.
    >
    > This AgeGroup field can also be used for black and white printouts and
    > other calculations or scripts rather than needing to plow through the
    > pile of separate ones each time. :o)
    >
    >
    >
    > Helpful Harry
    > "Just trying to help whenever I can." :o)

    John Weinshel Guest

  5. #4

    Default Re: changing color based on values

    In article <vnj0drs3ed8q7a@news.supernews.com>, "John Weinshel"
    <john@datagrace.biz> wrote:
    > Huh? Why not just one calc, returning a container, planted underneath the
    > data entry field? First, create some global containers and fill them with
    > rectangles colored appropriately. Then:
    >
    > Case(
    > TextToNum(Age Group) > 19 and TextToNum(Age Group) < 30,
    > Container_Red,
    >
    > TextToNum(Age Group) > 29 and TextToNum(Age Group) < 40,
    > Container_Blue
    > )
    >
    > ...etc. If the pattern persists, you could also use Choose().
    >
    > If you set that to not allow entry (or backwards-- I always get this one
    > confused), a cursor placed in the overlying field should work on that field,
    > for searches and entry. Set the calc propeties to expand and not maintain
    > proportions.
    Yep, that was the simpler graphic solution I wrote about (and would
    normally use myself), but the original person wanted the text to change
    colour, so that's the route I went through. :o)


    Helpful Harry
    "Just trying to help whenever I can." :o)
    Helpful Harry Guest

  6. #5

    Default Re: changing color based on values

    Concerning the searchability of the original field, here is how I gat
    around that ans till have th text change colors...

    Fir this example I will use a field where it would say "Yes" or "No".
    So, imagine you want the word "Yes" to be red and the "No" to be
    black.

    2 fields:

    ANSWER: Text
    YesHighlight: Calc, If(ANSWER = "Yes", ANSWER, "")

    Now put a clear-filled field that is 'YesHighlight' over the field
    ANSWER on your layout. Make sure you mark the overlay field text
    color as red.

    Now when you do searches you just check the ANSWER field.

    also, Make sure you set the 'YesHighlight' field to not be able to be
    entered on the layout.

    Hope that helps. I have some layouts which stack 6 or more different
    colors of text on a field. It's quite neat looking.

    -- FMP Junkie
    "Long live FMP!"
    FMP Junkie Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139