If I have multi occurrence items, how can I make sure a same value will not be entered twice?
I tried the codes below for a occ(2) item but it does't work.
*************************
if FIELD(1) = 1 and FIELD(2) = 1 then
errmsg("error");
endif;
if FIELD(1) in 1:3 and FIELD(2) in 1:3 then
errmsg("error");
endif;
*************************
How can I write the code?
Thank you
multi occurrence
-
- Posts: 1796
- Joined: December 5th, 2011, 11:27 pm
- Location: Washington, DC
Re: multi occurrence
Hello,
The easiest way to do is to use a loop, especially if you have more than two occurrences. See the attachment for an example. The relevant code is pasted here:
The easiest way to do is to use a loop, especially if you have more than two occurrences. See the attachment for an example. The relevant code is pasted here:
PROC VALUE
numeric i;
do i = 1 while i < curocc()
if VALUE(i) = VALUE then
errmsg("Must enter unique value");
reenter;
endif;
enddo;
numeric i;
do i = 1 while i < curocc()
if VALUE(i) = VALUE then
errmsg("Must enter unique value");
reenter;
endif;
enddo;
- Attachments
-
- noRepeat.zip
- (2.42 KiB) Downloaded 522 times
Re: multi occurrence
Thank you.
This will be very useful.
This will be very useful.
Re: multi occurrence
This is a nice tip.
But it will count a "blank" value as a value.
If I have an occ 10 and input data as 1,2,5,7 the only way to go to the next fiels is by using the command ctrl-/
Entering more than 1 blank value will generate an error message.
Is there any way exclude blank from the loop?
But it will count a "blank" value as a value.
If I have an occ 10 and input data as 1,2,5,7 the only way to go to the next fiels is by using the command ctrl-/
Entering more than 1 blank value will generate an error message.
Is there any way exclude blank from the loop?
Re: multi occurrence
This seems to work but not sure if it is the best way
numeric i;
do i = 1 while i < curocc()
if $(i) = notappl then
skip to next $
elseif $(i) = $ then
errmsg("Must enter unique value");
reenter;
endif;
enddo;
numeric i;
do i = 1 while i < curocc()
if $(i) = notappl then
skip to next $
elseif $(i) = $ then
errmsg("Must enter unique value");
reenter;
endif;
enddo;
Re: multi occurrence
While the code above do work for a multiple occurrence field in a single record, I could not make it work in a multiple occurrence field in a multiple occurrence (3) record. I tried various way but no luck.
How could I adapt this code in a multiple record?
How could I adapt this code in a multiple record?
-
- Posts: 1796
- Joined: December 5th, 2011, 11:27 pm
- Location: Washington, DC
Re: multi occurrence
If you want to skip blanks, it might be easiest (and clearest) to account for this before the loop:
PROC VALUE
numeric i;
if VALUE <> notappl then
do i = 1 while and i < curocc()
if VALUE(i) = VALUE then
errmsg("Must enter unique value");
reenter;
endif;
enddo;
endif;
numeric i;
if VALUE <> notappl then
do i = 1 while and i < curocc()
if VALUE(i) = VALUE then
errmsg("Must enter unique value");
reenter;
endif;
enddo;
endif;
Re: multi occurrence
Thank you.
It worked like this:
numeric i;
if VALUE <> notappl then
do i = 1 while i < curocc()
if VALUE(i) = VALUE then
errmsg("Must enter unique value");
reenter;
endif;
enddo;
else;
endif;
It worked like this:
numeric i;
if VALUE <> notappl then
do i = 1 while i < curocc()
if VALUE(i) = VALUE then
errmsg("Must enter unique value");
reenter;
endif;
enddo;
else;
endif;
Re: multi occurrence
Sometimes i have the same problem with different questionnaires unique number. Often, data entry operators or interviewers, enumerators uses the same ID for different's case when they uses separate computer: The codes you proposed isn't adapted because the case unique ID's doesn't have subscript and cant compare ID for different cases (previous and active case).
Please can you help me with? By exemple we can assign automatically ID's range for computers, data entry operators (1:500 for a operator's name, 500:100 to another name etc).
Other, it's possible to assign username and password for data entry operators?
Sincerely
Please can you help me with? By exemple we can assign automatically ID's range for computers, data entry operators (1:500 for a operator's name, 500:100 to another name etc).
Other, it's possible to assign username and password for data entry operators?
Sincerely
G.VOLNY, a CSProuser from Haiti, since 2004
-
- Posts: 1796
- Joined: December 5th, 2011, 11:27 pm
- Location: Washington, DC
Re: multi occurrence
You could add an alpha field to the IDs that would contain the computer's login name. Then you would populate that automatically by using the getusername function:
http://www.csprousers.org/help/html/get ... nction.htm
http://www.csprousers.org/help/html/get ... nction.htm