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!
Error message for incompatible multiple answers
-
- Posts: 572
- Joined: July 9th, 2012, 11:32 am
- Location: Islamabad, Pakistan
Re: Error message for incompatible multiple answers
Dear claudia;
variablename Data type should be Alpha in Dictionary
Field property will be "Check box" in the form design
The syntax will be:
a.
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;
Re: Error message for incompatible multiple answers
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!
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!
Re: Error message for incompatible multiple answers
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;
Re: Error message for incompatible multiple answers
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?
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?
-
- Posts: 572
- Joined: July 9th, 2012, 11:32 am
- Location: Islamabad, Pakistan
Re: Error message for incompatible multiple answers
Dear claudia;
In this case you can not select E with other options.
It means D, E, F can only be selected as single option.
a.
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;
Code: Select all
if poschar("DEF", $) >= 1 and length (Strip($)>1 then
errmsg (“Invalid entry.”)
$="";
reenter;
endif;
a.
Re: Error message for incompatible multiple answers
Perfect, that's what I was looking for. Thanks