AnsweredAssumed Answered

If script help

Question asked by CourtneyBird on Feb 1, 2012
Latest reply on Feb 3, 2012 by CourtneyBird

Title

If script help

Post

I'm new to File maker pro and am wrestling with writing scripts.

I have three fields. The first field is called "AGE", the second field is called "SEX" and the third is called "DIVISION"  The division category is determined by given age ranges and sex. So I assumed that I should use the "IF" function. What I would like to do is enter a person's age in the "AGE" field and "SEX" field and when I hit the tab key to got to the next field after entering the person's sex, that the proper division goes in the Division field. I assumed that I'd use nested if's since there are several divisions. They are as follows:

AGE:>=14<=39 and SEX ="M" returns "M1439" in the division field

AGE:>=40<=49 and SEX ="M" returns "M4049" in the division field

AGE:>=50<=59 and SEX ="M" returns "M5059" in the division field

AGE:>=60<=69 and SEX ="M" returns "M6069" in the division field

AGE:>=70 and SEX ="M" returns "M7099" in the division field

AGE:>=14<=39 and SEX ="F" returns "F1439" in the division field

AGE:>=40<=49 and SEX ="F" returns "F4049" in the division field

AGE:>=50<=59 and SEX ="F" returns "F5059" in the division field

AGE:>=60<=69 and SEX ="F" returns "F6069" in the division field

AGE:>=70 and SEX ="F"returns "F7099" in the division field

To do this does not sound like rocket science. I have used if functions in Excel and in Access, so it really is more of proper syntax and there are few examples that I could find that would give me any guidance. I worte a starter if script without nesting ifs just to test it, but nothing happens when I run the script -- not even an error message. I tried setting a script trigger in the sex field to "onobject enter" so see if that would do anything -- nothing.

I'm sure there are missing elements, but I'm stumped.

Here is the stript called Assign Divisions that I have written:

If(${Combined Marathon-Half-CCC}::AG ≥ 14 ≤ 39 and ${Combined Marathon-Half-CCC}::S  = "M";${Combined Marathon-Half-CCC}::DIV = "M1439";${Combined Marathon-Half-CCC}::DIV="Null")

End If

If that had worked, then I would have nested the other if options in the script.

The other part of this is that I want to be able to run this script globally so that it will assign the proper division to every record so that if I import a batch of records, I can assign divisions to the entire batch.

A screenship of the table is included.

Thanks for any help. I just need to get aimed in the right direction.

 

 

FM_Screenshot.jpg

Outcomes