Page 1 of 1
multiple check in the checkbox with multiple specify
Posted: March 17th, 2016, 5:42 am
by midoen
Guys, I have some problem with multiple check in the checkbox with multiple specify
here's my logic
Code: Select all
if pos("G",B22) = 1 then
skip to B22A
else if pos("H",B22) = 1 then
skip to B22B
else if pos("I",B22) = 1 then
skip to B22C
else if pos("J",B22) = 1 then
skip to B22D
else if pos("K",B22) = 1 then
skip to B22E
else if pos("L",B22) = 1 then
skip to B22F
else if pos("O",B22) = 1 then
skip to B22G
endif;
endif;
endif;
endif;
endif;
endif;
endif;
What I meant is if the items checked then it would be skipped to the following 'specify' items.
Any help is highly appreciated.
Regards,
Re: multiple check in the checkbox with multiple specify
Posted: March 17th, 2016, 7:14 am
by josh
Instead of testing if the result of pos is equal to 1 you should test if it is different from zero. It doesn't matter what position the letter is in as long as the letter is present in the checkbox string. Pos returns zero if the letter is NOT in the string so if pos is different from zero then the letter is in the string and the corresponding checkbox was checked. So instead of if
pos("G",B22) = 1 use
pos("G",B22) <> 0.
In addition, since you will have cases where you want to skip some of the fields and not others you can't put the skips immediately after the checkbox question. You need to break up the skips and either each one in the preproc of the field to be skipped or in the postproc of the preceeding field.
You would end up with something like this:
PROC B22A
preproc
if pos("G",B22) <> 0 then
skip to B22B
endif;
PROC B22B
if pos("H",B22) <> 0 then
skip to B22C
endif
PROC B22C
if pos("I",B22) <> 0 then
skip to B22D
endif;
Re: multiple check in the checkbox with multiple specify
Posted: March 17th, 2016, 7:24 am
by copernix2
Try this code.
Code: Select all
if pos("G",B22) > 0 then
skip to B22A
else if pos("H",B22) > 0 then
skip to B22B
else if pos("I",B22)> 0then
skip to B22C
else if pos("J",B22) > 0 then
skip to B22D
else if pos("K",B22) > 0 then
skip to B22E
else if pos("L",B22) > 0 then
skip to B22F
else if pos("O",B22) > 0 then
skip to B22G
endif;
endif;
endif;
endif;
endif;
endif;
endif;
Re: multiple check in the checkbox with multiple specify
Posted: March 17th, 2016, 11:42 am
by midoen
You guys are great!
Faith in humanity restored
I couldn't thank you enough guys

Re: multiple check in the checkbox with multiple specify
Posted: March 17th, 2016, 10:26 pm
by midoen
Hello, I have another issue, still related to checkbox, but different situation.
Suppose I have this multiple options question;
AID SUPPORT
SP08. What kind of aid did you receive?
A. Transportation Fee
B. Subsidized Service Fee
C. Counselling
D. Vitamin
E. Others (please specify)
F. No Aid
What I want is, if options. say, B and C checked, and if the enumerator accidentally check the option F, then the answer would be invalid, error message or anything.
This is my logic, but it doesn't seem to be working.
Code: Select all
if pos("F",SP08) <> 0 and pos ("F",SP08) <> 1 then
errmsg("Invalid option");
reenter;
endif;
Any help really appreciated, cheers
Regards,
Re: multiple check in the checkbox with multiple specify
Posted: March 18th, 2016, 3:24 am
by Saint
Can try this:
Code: Select all
if pos("F",SP08) <> 0 and length(strip(SP08)) > 1 then
errmsg("Option No Aid cannot be selected together with some other option");
reenter;
endif;
Re: multiple check in the checkbox with multiple specify
Posted: March 18th, 2016, 4:06 am
by midoen
Thank you, this works!
cheers