In article <45a441d0$0$16554$afc38c87 (AT) news (DOT) optusnet.com.au>, "TM"
<toni (AT) dataspecifics (DOT) com.au> wrote:
Quote:
FMP 8.5 Windows XP
Hi there,
I have a checkbox field which I need a result to show based on the text
selected (can be 1 or more selected checkboxes).
My issue is if they select more than one checkbox it wipes out my if
statement, I realise I must be using the wrong operator in the script but am
not sure which is the correct one to use... I am pasting my statement in the
hope someone can point me to my error.
If ( Construction Type = "Brick Veneer" or "Brick" or "Brick Cavity" or
"Brick rendered"; Brickwork Condition; "Not Applicable")
I need it to be either one of these answers or all of them :0)
Thanks in advance. |
There's two problems here.
Firstly, you don't quite understand how the If statement (and Case
statement) work.
To FileMaker, and pretty much all programs that have an If statement,
the test
If ( Construction Type = "Brick Veneer" or "Brick"
or "Brick Cavity" or "Brick rendered", ...
is really nonsense, at least it is in terms of what you're trying to
test for. You can't just "or" other result values onto the end or each
other. Instead you have to re-type the test each time. It's also best
to put parentheses around each test to make sure they are performed
separately.
eg.
If ( (Construction Type = "Brick Veneer")
or (Construction Type = "Brick")
or (Construction Type = "Brick Cavity")
or (Construction Type = "Brick rendered"), ...
Checkboxes are simply normal fields that are formatted to display
differently. When the user turns on a checkbox that value is appended
to the end of the field's current data, with each "on" value separated
by carriage returns. Put a second copy of the same field onto the
layout, but set it's formnat to be "Standard Field" - stretch it taller
and then as you play with various checkbox options you'll see what the
field is doing with its data.
This means that a simple test
If (Construction Type = "Brick Veneer")
will only work if the checkbox "Brick Veneer" is turned on ... and
ONLY that option is turned on.
You don't say what the possible checkbox values are, so it's not
possible to give you the correct test, but what you would normally do
is use the PatternCount function to check whehter the field contains
the appropriate value anywhere in it.
For example, if the checkbox field has the possible options:
Smurf
Yogi Bear
Top Cat
Fred Flintstone
Then you can test to see if the field has "Smurf" turned on by using:
If (PatternCount(TextField, "Smurf") = 1, "Smurf is On",
"Smurf is off")
You can see if either "Smurf" or "Top Cat" is turned on (including
having both turned on) by a test like:
If ( (PatternCount(TextField, "Smurf") = 1)
or (PatternCount(TextField, "Top Cat") = 1),
"Smurf and / or Top Cat is on",
"Neither Smurf or Top Cat is on")
By the look of your test, you appear to be trying to say that if ANY
checkbox with "Brick" in it is turned on then you want to return the
result from the field Brickwork Condition.
The easiest way to do this is to simply ignore the actual checkbox
values and look to see if the word "Brick" exists.
eg.
If (PatternCount(Construction Type, "Brick") = 0,
"Not Applicable",
Brickwork Condition)
If "Brick" doesn't exist (ie. none of the "Brick" options are turned
on) then the PatternCount will find no "Brick" and return 0.
Helpful Harry
Hopefully helping harassed humans happily handle handiwork hardships ;o)