First set of radio buttons are 'Normal" & "Abnormal"
Second set of radio buttons are "Disease Present" or "Disease Absent"
Both are based on their respective value lists.
In the second set of radio buttons, in Layout mode, right click on this field, select script triggers.
Select OnObjectModify and attach this script:
If [radio button2Table::radio button 2 Field] = "Disease Present" //select table::field from second radio button set. Disease Present is one of the values in the value list.
Set Field [radio button1Table::Field; "Abnormal"] //select table::field from first radio button set. "Abnormal" is one of the values in the value list
Set Field [[radio button1Table::Field; "Normal"] //select table::field from first radio button set. "Normal" is one the other value in the value list
Edit: I would also go into Manage Database to each radio button field, double click to get options, go to the Auto_Enter Tab, select "Calculated Value" and enter this calculation (originally posted by Mr. Raybaudi):
GetValue ( Self ; ValueCount ( Self ) )
Uncheck the box "Do not replace existing values of field (if any).
This auto-enter calculation will prevent anyone from shift-clicking and selecting both buttons
I would also disallow field entry in Browse Mode for the first set of radio button (being the initial value is set as normal, and you only want to change it via the other radio button set). I would allow it in find mode, so you could search records by Normal or Abnormal
An auto-enter calculation could update field A to the other radio button value without needing a script.
Case ( Field B = "Disease Present" ; "Abnormal" ;
Field C = "Disease Present" ; "Abnormal" ;
Field D = "Disease Present" ; "Abnormal" ;
Be sure to clear the "do not replace existing values..." check box.
Thanks for both your replies!
Steve: I tried your method, but I did not have much success yet. This was probably me doing something wrong with the script as I am new to this. I will try it again and ask you if it does not work out.
PhilModJunk: Your method was easy and it did give me a result! I tried it only with Field B. Unfortunately, not the result I expected. When I used your code, Field A does auto-enter, but it auto-enters "Normal". This is what I typed in the "Calculate" under Field A:
Case ( Field B = "2" ; "1" = Self)
where 2= disease present and 1 = abnormal. Field A auto-enters "0" which is Normal.
I suggest that you look up Case in FileMaker Help.
Your use of Case does not match mine. You need pairs of expressions. the first expression in each pair is a Boolean expression that evaluates as either True or False. The second expression evaluates only if the first expression of the pair evaluates as True and it is the first Boolean expression in the Case to evaluate as True.
A final result expression can be added at the end with no paired Boolean expression as the "else" expression to be the value returned if none of the preceding Boolean expressions evaluate as True.
Your "result expression" is "1" = Self and this will return a 1 (True) if the value in the field is currently 1.
If your radio buttons are entering 1 for abnormal and 2 for disease present (that doesn't really make sense to me and you don't indicate what value is entered for "normal"), then the original Case expression that I posted would look like this:
Case ( Field B = 2 ;1 ;
Field C = 2 ; 1 ;
Field D = 2 ; 1 ;
Note that if the none of the fields B, C or D have the value 2, then the value in Field 1 remains unchanged due to self being specified as the "else" result expression.
PhilModJunk: I have no idea what I did wrong the first time either. This time around, I just exactly copied from your suggestion
Case ( Field B = "2" ; "1" ;
Field C = "2" ; "1" ;
Field D = "2" ; "1" ;
and it worked like a charm :) :)
[Normal was 0 by the way. I use 0,1,2 etc throughout my database for all fields/ to make it easy for statistical analysis when exported to Excel later.]
Thank you so much!! I will be using this calculation at many points in my database.