multiple check in the checkbox with multiple specify

Discussions about CSEntry
Post Reply
midoen
Posts: 6
Joined: March 7th, 2016, 10:37 pm

multiple check in the checkbox with multiple specify

Post 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,
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: multiple check in the checkbox with multiple specify

Post 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;
copernix2
Posts: 18
Joined: November 23rd, 2014, 7:46 am

Re: multiple check in the checkbox with multiple specify

Post 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;
midoen
Posts: 6
Joined: March 7th, 2016, 10:37 pm

Re: multiple check in the checkbox with multiple specify

Post by midoen »

You guys are great!
Faith in humanity restored
I couldn't thank you enough guys :)
midoen
Posts: 6
Joined: March 7th, 2016, 10:37 pm

Re: multiple check in the checkbox with multiple specify

Post 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,
Saint
Posts: 63
Joined: November 22nd, 2013, 4:59 am

Re: multiple check in the checkbox with multiple specify

Post 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;
midoen
Posts: 6
Joined: March 7th, 2016, 10:37 pm

Re: multiple check in the checkbox with multiple specify

Post by midoen »

Thank you, this works!
cheers
Post Reply