Set field [ yourtable::checkboxfield ; list ( yourtable::checkboxfield ; "newvalue" ) ]
Thanks AGAIN Phil. I doubt I'd have figured that one out without a lot of reading….somewhere. I searched around this forum but didn't find it. It's almost hard to believe a "new" question can be asked here. This works, with one caveat. If the field is already set, it ADDS the same field to the list. So, now there are duplicate values in my list. I tried this: If List ( Names::Type ; "Rider" ) = "" …but that doesn't help me. I guess now I'm looking for the function that says something like If Rider exists in Names::Type Then <do nothing> Else <your script line>. Again, nothing jumps out at me looking through the existing functions.
In many cases, the duplicate values won't cause any problems. A checkbox format on the field, for example will continue to look and function correctly even though there are multiple copies of the same value listed in the field.
Here is a more sophisticated calculation, that only adds the value if it is not already selected:
Set Field [ YourTable::CheckBoxField ;
IF ( IsEmpty ( FilterValues ( YourTable::CheckboxField ; "NewValue" ) ) ; List ( YourTable::CheckboxField; "newvalue") ; YourTable::CheckBoxField) ]
That does the trick. You're right about it looking the same. Only weirdness is if someone manually unchecked the field, it doesn't APPEAR to uncheck. It is, of course, removing the last entered value in the array, but leaves the first. This version works like a charm. Just trying to make sure I understand this statement. Is that IF portion a shortened form of an if-else? I.e. If "NewValue" is not in the list, set to new value, otherwise just set it to what it is?
It's an If function and you can look it up in FileMaker help.
If ( boolean Expression ; True Expression ; False Expression )
If boolean Expression evaluates as True or a number value other than 0 or null, the True Expression is evaluated to return a value. If the boolean expression evaluates as False, null or a zero, the False expression is evaluated to return a value. In my last example:
IF ( IsEmpty ( FilterValues ( YourTable::CheckboxField ; "NewValue" ) ) ; List ( YourTable::CheckboxField; "newvalue") ; YourTable::CheckBoxField)
The boolean expression is red, the True expression is green and the false expression is blue.
Right. Exactly what I thought.