This is a public Forum  publicRSS

Forum post

    Aga
    Changing the color of a Button/Field without using...Answered
    Forum post posted April 4, 2013 by Aga 
    153 Views, 4 Comments
    Title:
    Changing the color of a Button/Field without using Conditional Formatting
    Post:

    Hello,

    I have two cases:

    1. Would someone have an example on how to change a button's color when the button is pressed without using conditional formatting. The conditional formatting does not work on the IWP.

    2. I would like to have a button that sits on top of some fields in a portal, if that specific portal row has a record that has an empty filed I want this portal row to be highlighted, therefore I would like that button to change color. Again I need this to work on the web, therefore I cannot use conditional formatting.

    Thank you! :)

    Best Answer

    PhilModJunk

    We used to conditionally change colors on a layout long before we had conditional formating to make it easier. Those "old school" methods still work in IWP.

    Define a container field in your database. This can be a field with global storage or  field in a related table where X is used as the operator in the relationshp. This field's value has to be accessible for every record in your table.

    Insert a colored rectangle into this container field of the color that you want to display as the conditional background color.

    Now define a field in your portal's table using the same expression that you would use in a conditional format expression, but put it inside an If or Case Function and refer to the container field when the expression evaluates as True. Select "Container" as this calculation field's result type.

    Place this field underneath transparent copies of your fields where you want this "highlight" color to appear.

    Here's a sample expression that returns the Highlight color when Field1 is Empty:

    If ( IsEmpty ( Field1 ) ; Globals::GlobalContainerField ) // clear the "do not evaluate if all referenced fields are empty" check box.

    When you place this calculation field on your layout, use data formatting to specify that the container field both reduce and enlarge to fit the field and clear the "maintain proportions" check box so that the entire field fills with color when the calculation evaluates as True.

    Answer

     

    • PhilModJunk

      We used to conditionally change colors on a layout long before we had conditional formating to make it easier. Those "old school" methods still work in IWP.

      Define a container field in your database. This can be a field with global storage or  field in a related table where X is used as the operator in the relationshp. This field's value has to be accessible for every record in your table.

      Insert a colored rectangle into this container field of the color that you want to display as the conditional background color.

      Now define a field in your portal's table using the same expression that you would use in a conditional format expression, but put it inside an If or Case Function and refer to the container field when the expression evaluates as True. Select "Container" as this calculation field's result type.

      Place this field underneath transparent copies of your fields where you want this "highlight" color to appear.

      Here's a sample expression that returns the Highlight color when Field1 is Empty:

      If ( IsEmpty ( Field1 ) ; Globals::GlobalContainerField ) // clear the "do not evaluate if all referenced fields are empty" check box.

      When you place this calculation field on your layout, use data formatting to specify that the container field both reduce and enlarge to fit the field and clear the "maintain proportions" check box so that the entire field fills with color when the calculation evaluates as True.

    • Aga

      Hello PhilModJunk!

      Thank you very much for your answer and help! I have tried what you have suggested and sofar success!

      Have a great day!

    • Aga

      Hello,

      I have two more problems:

      1. I just realized that this container field only "remembers" the pasted colored rectangle per session. The moment i log out of FM and log back in, the container is empty. How can I ensure that the container field remembers that I pasted a colored rectangle?

      2. The Field1 in my case has to sit on top of the other entry fields in the portal. I can do this with conditional formatting because the box is not a field and it will only show when the current row of the portal is empty.  By using the Field1 as you suggested, and this Field1 sitting on top of other fields, now I am unable to enter data to those fields. Is there something I can do about this?

      Thanks for your time.

    • PhilModJunk

      1. If you are hosting your file on another computer with FileMaker Pro, go to that computer, open it without using Open Remote and set the value in the global field there. If you are using Filemaker Server to host your file, pull the file down off the server, open it with Filemaker Pro and load the global field with the graphic.

      2. That's why I said use transparent data fields and put this field underneath them. That way, they remain accessible.