Hi - I am trying to work out how to update the correct field in a household roster from a value in a later form. I have a field called "form entered" in my roster which is set to zero when a new roster record is added. Some of the people in the roster will go on to be interviewed, and when their interview is complete I want the "form entered" value in their roster to update to another value from a "form status" field in their questionnaire. This is so I can then use the show function to display those from the roster whose forms have not been completed. If I use something like:-
FORM_ENTERED (i)=FORM_STATUS;
It will compile but there is nothing here to tell it which record to update. Ideally I'd like to make use of the person ID (present in both the roster and the subsequent form) to ensure the right record is updated , but I cannot make this work. I have a feeling I should be using the seek command somehow but I'm not sure how. Any advice or help with this would be very much appreciated.
Many thanks
Keith
Updating correct roster record from later record
-
Gregory Martin
- Posts: 1947
- Joined: December 5th, 2011, 11:27 pm
- Location: Washington, DC
Re: Updating correct roster record from later record
One of the problems is that when you want to refer to numeric fields that come later in the form, you will have to use the visualvalue function. If you refer to them without that, they will appear as notappl (blanks). But this poses a problem for you if you want to use functions like show and seek. They don't use the visualvalue so they will appear as blanks. There are ways to get around that with seek, as you can write a loop and use visualvalue within the loop. But there is no direct workaround for show.
An indirect substitute for show is to put the values that you care about in some items from a working storage dictionary, and then you'll be able to use show on those items. (When making the assignments, you'll have to make the assignment using the visualvalue.) This is a lot of programming, but it will work. See the attached application, and the below code:
An indirect substitute for show is to put the values that you care about in some items from a working storage dictionary, and then you'll be able to use show on those items. (When making the assignments, you'll have to make the assignment using the visualvalue.) This is a lot of programming, but it will work. See the attached application, and the below code:
PROC PERSON_TO_ENTER
preproc
PERSON_TO_ENTER = 0;
if totocc(PEOPLE000) > 0 then
numeric ctr;
do ctr = count(WS_DICT.WS_REC) while ctr >= 1 by -1 // delete any occurrences that may already exist
delete(WS_REC(ctr));
enddo;
do ctr = 1 while ctr <= totocc(PEOPLE000)
if visualvalue(SEX(ctr)) = 2 then
numeric nextOccurrence = count(WS_DICT.WS_REC) + 1;
insert(WS_REC(nextOccurrence));
SHOW_TEXT(nextOccurrence) = maketext("%s, a female aged %d",strip(NAME(ctr)),visualvalue(AGE(ctr)));
OCCURRENCE(nextOccurrence) = ctr;
endif;
enddo;
numeric selection = show(WS_DICT.WS_REC,SHOW_TEXT,title("Select a woman to edit"));
if selection > 0 then
PERSON_TO_ENTER = OCCURRENCE(selection);
endif;
endif;
noinput;
postproc
if PERSON_TO_ENTER > 0 then
move to NAME(PERSON_TO_ENTER);
endif;
preproc
PERSON_TO_ENTER = 0;
if totocc(PEOPLE000) > 0 then
numeric ctr;
do ctr = count(WS_DICT.WS_REC) while ctr >= 1 by -1 // delete any occurrences that may already exist
delete(WS_REC(ctr));
enddo;
do ctr = 1 while ctr <= totocc(PEOPLE000)
if visualvalue(SEX(ctr)) = 2 then
numeric nextOccurrence = count(WS_DICT.WS_REC) + 1;
insert(WS_REC(nextOccurrence));
SHOW_TEXT(nextOccurrence) = maketext("%s, a female aged %d",strip(NAME(ctr)),visualvalue(AGE(ctr)));
OCCURRENCE(nextOccurrence) = ctr;
endif;
enddo;
numeric selection = show(WS_DICT.WS_REC,SHOW_TEXT,title("Select a woman to edit"));
if selection > 0 then
PERSON_TO_ENTER = OCCURRENCE(selection);
endif;
endif;
noinput;
postproc
if PERSON_TO_ENTER > 0 then
move to NAME(PERSON_TO_ENTER);
endif;
You do not have the required permissions to view the files attached to this post.
-
Keith Tomlin
- Posts: 56
- Joined: March 23rd, 2014, 9:30 am
Re: Updating correct roster record from later record
Hi Greg
Thank you for your detailed responses, I really appreciate it. Your suggestion for using the 'skip to next' command in order to leave one occurrence early and move to the next seems to work well, and there are several points in my questionnaire where this will be helpful.
However, regarding the PreEntryShow example that you attached, I'm afraid that CSPro data entry crashes when I enter data into the screen, save the case and then return to it (I get the generic "CSPro has stopped working" message). I've tried it on two computers with the same result. Perhaps I'm doing something wrong? Also, I'm not sure if I was entirely clear about what I'm trying to do - I have a roster form and a subsequent woman form, and I want to update a value in the roster from a value in the woman form - then I can call upon the roster again (using show) but use the updated value in the roster as part of the show criteria. So for example, if I begin data entry and use the show command to list women who need women records, then enter the data for a woman, and then skip to the next occurrence and use the show list again, I no longer want it to list the name and number of the woman whose data have been entered. Hence I'm thinking that if I update the roster to indicate that her data have been entered, I can then use this as part of the show criteria. My difficulty is in using a subcript to refer to the correct woman's roster record.
Please don't hesitate to let me know if I'm still not being clear, and thanks again.
Best wishes
Keith
Thank you for your detailed responses, I really appreciate it. Your suggestion for using the 'skip to next' command in order to leave one occurrence early and move to the next seems to work well, and there are several points in my questionnaire where this will be helpful.
However, regarding the PreEntryShow example that you attached, I'm afraid that CSPro data entry crashes when I enter data into the screen, save the case and then return to it (I get the generic "CSPro has stopped working" message). I've tried it on two computers with the same result. Perhaps I'm doing something wrong? Also, I'm not sure if I was entirely clear about what I'm trying to do - I have a roster form and a subsequent woman form, and I want to update a value in the roster from a value in the woman form - then I can call upon the roster again (using show) but use the updated value in the roster as part of the show criteria. So for example, if I begin data entry and use the show command to list women who need women records, then enter the data for a woman, and then skip to the next occurrence and use the show list again, I no longer want it to list the name and number of the woman whose data have been entered. Hence I'm thinking that if I update the roster to indicate that her data have been entered, I can then use this as part of the show criteria. My difficulty is in using a subcript to refer to the correct woman's roster record.
Please don't hesitate to let me know if I'm still not being clear, and thanks again.
Best wishes
Keith
-
Keith Tomlin
- Posts: 56
- Joined: March 23rd, 2014, 9:30 am
Re: Updating correct roster record from later record
Hi Greg
I have a feeling I may have an answer to this particular problem. I hadn't really stopped to think that the woman's ID number on the woman form (WOMAN_ID) is going to be the same as her ID number in the previous roster (PERSON_ID). On the roster I have a field "DATA_STATUS" and on the woman's form a field "WOMAN_STATUS", and I want to update the DATA_STATUS field in the roster with the WOMAN_STATUS value from her form. From the postproc of the WOMAN_STATUS field It seems that:-
DATA_STATUS(WOMAN_ID)=$;
will achieve this, where I just use the WOMAN_ID as the subscript in the roster to identify the woman's record and update her status field.
Sorry if I wasn't entirely clear about what I wanted to do.
Now I'm struggling with getting a show list when re-entering a form to just list those women who have a status of "re-visit", and then navigate directly to the correct record. So more questions to come, I'm sure....
Best wishes
Keith
I have a feeling I may have an answer to this particular problem. I hadn't really stopped to think that the woman's ID number on the woman form (WOMAN_ID) is going to be the same as her ID number in the previous roster (PERSON_ID). On the roster I have a field "DATA_STATUS" and on the woman's form a field "WOMAN_STATUS", and I want to update the DATA_STATUS field in the roster with the WOMAN_STATUS value from her form. From the postproc of the WOMAN_STATUS field It seems that:-
DATA_STATUS(WOMAN_ID)=$;
will achieve this, where I just use the WOMAN_ID as the subscript in the roster to identify the woman's record and update her status field.
Sorry if I wasn't entirely clear about what I wanted to do.
Now I'm struggling with getting a show list when re-entering a form to just list those women who have a status of "re-visit", and then navigate directly to the correct record. So more questions to come, I'm sure....
Best wishes
Keith