Unexpected behaviour of show function.

Discussions about CSEntry
Post Reply
Keith Tomlin
Posts: 56
Joined: March 23rd, 2014, 9:30 am

Unexpected behaviour of show function.

Post by Keith Tomlin »

Hi -

I use a show function to display people from a household roster (ROST_REC) who are eligible for interview. In the code below, Q114A = person number, Q114B = Name, Q114J = status and Q114E = eligibility for interview. Only those with eligibility of 1 are shown. The code below works OK:-

function SelectedWoman();
numeric wno, wid = 0;
wno = show(ROST_REC,Q114A,Q114B, Q114J where Q114E=1,Title("ID","Name", "Interview Status"));
if wno > 0 then
wid = Q114A(seek(Q114E=1, @wno));
endif;
SelectedWoman = wid;
end;

However, I want to add a further criteria, to only show those eligible people who have not yet been interviewed. I've added another item to the end of the roster - Q114K - to do this, and I want to include this in the show function where Q114K=0, ie:-
function SelectedWoman();
numeric wno, wid = 0;
wno = show(ROST_REC,Q114A,Q114B, Q114J where Q114E=1 and Q114K=0,Title("ID","Name", "Interview Status"));
if wno > 0 then
wid = Q114A(seek(Q114E=1 and Q114K=0, @wno));
endif;
SelectedWoman = wid;
end;

But this doesn't work - if I have two eligible people it now only shows the first, regardless of interview status. I think this might have something to do with the new item being at the end of the roster? But I can't figure out what the problem is. I would really value any help with this, as I can't see where I'm going wrong.

Many thanks

Keith
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Unexpected behaviour of show function.

Post by josh »

I don't see anything obviously wrong with the code. If you post your app or at least a small piece of it that I can test with then I can take a closer look.
Keith Tomlin
Posts: 56
Joined: March 23rd, 2014, 9:30 am

Re: Unexpected behaviour of show function.

Post by Keith Tomlin »

Hi Josh

I'm still puzzled by this part of my code not working. Would you be able to take a look at this section of the application that I sent to you last week? Let me know if I need to send the application again.

Many thanks

Keith Tomlin
London School of Hygiene & Tropical Medicine.
savy
Posts: 163
Joined: December 27th, 2012, 1:36 pm

Re: Unexpected behaviour of show function.

Post by savy »

There is a problem with your logic. If you check the Q114K value on your second person, you would have noticed that it is NOTAPPL and not 0.
The reason is you are ending the group midway of your person record. Since you have not reached Q114K the system has its value as notappl.
Either you have to move your check to the last field on your group or change your condition to "where (Q114E=1 and (Q114K=0 or Q114K=NOTAPPL))"

-Savy
Post Reply