Error message for incompatible multiple answers

Discussions about CSEntry
Forum rules
New release: CSPro 8.0
Post Reply
claudia
Posts: 57
Joined: May 9th, 2017, 6:23 am

Error message for incompatible multiple answers

Post by claudia »

Hi,
I was wondering how to create an error message in case some incompatible answers are selected in a question allowing for multiple answers; e.g.

Q1: What kind of healthcare professional(s) did you consult?

A- family doctor
B- gynaecologist
C- phisiotherapist
D- none

Answer "D" is incompatible with any other answer.

Many thanks!
khurshid.arshad
Posts: 571
Joined: July 9th, 2012, 11:32 am
Location: Islamabad, Pakistan

Re: Error message for incompatible multiple answers

Post by khurshid.arshad »

Dear claudia;

variablename Data type should be Alpha in Dictionary
Field property will be "Check box" in the form design

The syntax will be:

Code: Select all

Proc variablename

If pos(“D”,$) >=1 and length (strip(($))>1  then 
	Errmsg (“You can not select “None” with other options.”)
	$=””;
	Reenter;
Else
Endif;

a.
claudia
Posts: 57
Joined: May 9th, 2017, 6:23 am

Re: Error message for incompatible multiple answers

Post by claudia »

That's incredibly helpful thanks!

In case anyone uses the same command, I had to modify a couple of details because my cspro wasn't happy about an extra braket and some inverted commas, so this is what I used:

if pos("D",$) >=1 and length (strip($))>1 then
errmsg ("You cannot select none at the same time as other options");
$="";
Reenter $;
Else
Endif;

I have an additional question:
how does the command change if I have two or three options which can only be selected by themselves? Eg.

Q1: What kind of healthcare professional(s) did you consult?

A- family doctor
B- gynaecologist
C- phisiotherapist
D- none
E- don't know

In this case, answers "D" and "E" are incompatible with any other answer.

Thank you!
sah
Posts: 97
Joined: May 28th, 2015, 3:16 pm

Re: Error message for incompatible multiple answers

Post by sah »

If i should understand you well, that you cannot select the two option at same time then ....

Code: Select all

if pos("D", $) >= 1 then
     errmsg (“You can not select “None” with other options.”)
 reenter;
elseif pos("E", $) >= 1 then
   errmsg("You can not select 'DK,with other options");
 reenter;
endif;
claudia
Posts: 57
Joined: May 9th, 2017, 6:23 am

Re: Error message for incompatible multiple answers

Post by claudia »

Thanks for your reply.

The code worked fine to create an error message if someone selects options "D" and "E" at the same time. However, I was also looking for an error message in case someone selects for ex. A, B, and E (seen as it's incompatible to say you consulted a healthcare professional AND you don't know). How do I create a command for this?

I also have another multiple answer question where there are 3 answer possibilities (D-F) which are incompatible with the other options (A-C): e.g.

A- family doctor
B- gynaecologist
C- phisiotherapist
D- "none"
E- "don't know"
F- "Not applicable"


Could you kindly advise for a command in this last case too?
khurshid.arshad
Posts: 571
Joined: July 9th, 2012, 11:32 am
Location: Islamabad, Pakistan

Re: Error message for incompatible multiple answers

Post by khurshid.arshad »

Dear claudia;

Code: Select all

if pos("D", $) >= 1 then
     errmsg (“You can not select “None” with other options.”)
 reenter;
elseif pos("E", $) >= 1 and length(strip($)>1 then
   errmsg("You can not select 'DK,with other options");
 reenter;
endif;
In this case you can not select E with other options.

Code: Select all

if poschar("DEF", $) >= 1  and length (Strip($)>1 then
     errmsg (“Invalid entry.”)
$="";
 reenter;
endif;
It means D, E, F can only be selected as single option.

a.
claudia
Posts: 57
Joined: May 9th, 2017, 6:23 am

Re: Error message for incompatible multiple answers

Post by claudia »

Perfect, that's what I was looking for. Thanks
Post Reply