Yes, you can.
The Set Field [ ] script step must be modified with something like this:
Set Field [ YourField ; Let ( $color = Abs ( $color + 1 ) ; Case( $color ; "yourValueHere" ) )]
The conditional formatting for that button must be:
Formula = not IsEmpty ( YourField )
The result will be that, clicking the button once, YourField will contain YourValueHere and the button will change its color; re-clicking will set YourField to empty and the button will return to its default color.
I'm sorry. I'm not following you. I'm fairly new at this and not yet very good at formulas and operators. =) If I modify the set field portion of my script, am I placing that info in the target field or calculated result?
Thanks for your help!
It sounds like you've already set up specialized fields for these buttons. You can do something like this:
Set all the fields to a value of 0.
When the user clicks one of the fields, say Button1, have the script add a line for:
SetField (Button1 ; 1)
which changes the value of Button1 from 0 to 1.
Then set up your conditions so that if Button1 = 1, you get the new color.
That said, if you have 10 buttons and you only want the last one clicked to be colored, you'll have to set each script to go through the other 9 buttons and set them all to 0.
I think this covers what you're looking for. :)
> I modify the set field portion of my script...
Please, be clear: have you a button with only one step or a button that fires a script of more than one step ?
> am I placing that info in the target field or calculated result?
Yes, I have buttons that fire a script with more than one step. Basically, it is setting other fields, but not changing layouts or displaying any dialog. But, I think I got it figured out. I just set a dialog to let the user know that they had chosen a recipient. Seems easier at this point. =)
Thank you so much for your help!!
I choose that way to solve your problem thinking that the button has only a step ( with that as a limitation ).
So there are even simpler ways if your button fires a whole complex script.
By simpler ways, do you mean using Custom Dialog? Or something simpler? =)
no, back to the topic, conditional formatting the button color.
I thought I would try to come back to this and give it a shot, but I'm still not having any luck. I do have 10 buttons, which are fields in a related table (also they are a calculated field). When you press on any of them, it runs a script that sets other fields and shows custom dialog based on the script parameter. When I try to configure a set field step to change the color, it always ends up giving me a message that it cannot perform that specific step because the field is not modifiable. Is this because it is a calculated field? Or because I changed the field to a button?
When I try to configure a set field step to change the color, it always ends up giving me a message that it cannot perform that specific step because the field is not modifiable.
you can't SET the contents of a calculated field but, if you have FM 9 ( at least ) , you can apply to that field a 'conditiona formatting' based on a calc to change the fill and/or the text color.
Which version of FM do you have ?
Okay, so I was messing around with some of the new templates in FileMaker Pro 10 (which I use), and noticed in the Contact Management file there are fields and scripts that essentially do what I am trying to do. When you go to list view, you can choose to sort by Company, Name, Email, etc. And, when you choose which sort you would like, it changes the image. They do this with global, container and calculated fields. So, I made a container field with a checkmark image, then I made a container field with a blank image (I know this is not the way I am suppose to do it! =), Then I added the calculated field next to my button, so that it can change from blank to the checkmark depending on the buttons pressed. I can get the checkmark to appear no problem, but I'm still trying to figure out how to make it go away when another button is pressed without making my script terribly long. I am really new at this, so if you can give any advice, you may want to really spell it out for me. =)
Thank you so much!
Ok, back to topic.
Create a new file ( Test ) with only 3 fields:
A ( with the option to auto-enter a serial number starting from 1 step 1 )
B ( with the option to auto-enter as data: 1 )
C = calculated field with calc: A*B
In Layout Mode:
1) delete field A and field B
2) select the field C
3) from menu: Format >> Conditional... >> Add >> Condition >> Formula is : not Mod ( Self ; 2 )
4) check 'Bold' and choose yellow as the 'Fill Color'
In Browse Mode View as Table...
Now, every other time you add a new record, the Fill of the calculated field will be yellow and the text bold.
This demostates that a calculated field CAN be formatted based on a calculation.
Finally fixed it via a calculated field (container with either a checkmark or no checkmark). This seems to work a bit better for me. Thanks!!
I wandered through conditional formatting for half an hour trying to figure out how to do this.
This solution works perfectly!