Problems with SEEK AND SELECT ERROR MSG FUNCTIONS!! Urgent

Discussions about CSEntry
Post Reply
gbos
Posts: 51
Joined: June 18th, 2015, 7:49 pm

Problems with SEEK AND SELECT ERROR MSG FUNCTIONS!! Urgent

Post by gbos »

Attached is the survey am working on.


I have a household roster with Household IDs and Age. In my case HHold ID is s1q1_idno and age is s1q4a. I have another record type where I have a question s7aq3 which asks for a random ID Number to be inserted from the roster provided the age corresponding to that ID is more than 18 years.
For any IDNUM you may put in s7aq3, the program should be able to check that the age corresponding to that ID from the Household roster is more than 18 years.
I used seek function as follows :
Numeric householdloanid = seek(s1q4a(s1q1_idno));
If householdloanid<18 then
Errmsg(…..);
Endif;
This did not work. Can anyone help me.
In another separate development, I am seeking for another help on select error function. It worked for me when I used fewer variables. However, when I attempted to use larger list of variables as shown in the coding below, it wouldn’t compile.
calculatedTotal = S3BQ3+S3BQ4+S3BQ5+S3BQ6+S3BQ7+S3BQ8+S3BQ9+S3BQ10+S3BQ11+S3BQ12;
If S3BQ14 <> calculatedTotal THEN
errmsg(8,calculatedTotal,S3BQ14)
Select("Change Sch. & registration fee, Q3",S3BQ3, "Change PTA Contibutions, Q4",S3BQ4,
"Change Uniform & Sports Expenses,Q5",S3BQ5,"Change Text Books Costs, Q6",S3BQ6,"Change Sch. Supplies,Q7",S3BQ7, "Change Transport cost, Q8", S3BQ8,"Change Lunch & Pocket money Cost, Q9",S3BQ9,"Change Examination Fees, Q10",S3BQ10, "Change Extra Classes cost, Q11",S3BQ11,"Change Other Expenses, Q12", S3BQ12, "Change Transport cost, Q8", S3BQ8,"Change Lunch & Pocket money Cost, Q9",S3BQ9,"Change Examination Fees, Q10",S3BQ10, "Change Extra Classes cost, Q11",S3BQ11,"Change Other Expenses, Q12", S3BQ12);
endif;
IHS1.zip
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Problems with SEEK AND SELECT ERROR MSG FUNCTIONS!! Urg

Post by josh »

For the first issue I don't think you want to use seek. Seek finds the index of the first row in roster that matches a condition. So seek(S1Q4A < 18) would give you the index (the row number) of the first row in the roster for which the age is less than 18.

Imagine that you have the following household:

LineNo(S1Q1_IDNO) Name(S1Q2) Age(S1Q4A)
---------------------- --------------- --------------
1 John 40
2 Jacob 17
3 Schmidt 30

Then seek(S1Q4A < 18) would return 2 since Jacob is on row 2 and has age less than 18.

If you want to test if the age of a PARTICULAR row in the roster is less than 18 then you do not need to use seek. For that you just use the subscript. To test if the person in row 2 (Jacob) is under 18 then you would do:

if S1Q4A(2) < 18 then...

or to test if Schmidt in row 3 is under 18 you would do:

if S1Q4A(3) < 18 then...

In your logic you are using both the subscript and seek which doesn't make sense. You only use seek when you don't know the row number and you want to find the row that matches a particular condition.

If you want to test the age for the ID number in S7AQ3 you would do this in two steps. First you get the row number that matches the IDNO in S7AQ3:

numeric lineNumberMemberObtainedLoan = seek(S1Q1_IDNO=S7AQ3);

Then use the subscript to get that persons age:

if S1Q4A(lineNumberMemberObtainedLoan) < 18 then...

For the second issue there is a limit of 5 buttons when you use select with the errmsg command.
gbos
Posts: 51
Joined: June 18th, 2015, 7:49 pm

Re: Problems with SEEK AND SELECT ERROR MSG FUNCTIONS!! Urg

Post by gbos »

I amended my coding as follows:

numeric lineNumberMemberObtainedLoan=seek(s1q1_IDNO=s7aq3);

if s1q4a(lineNumberMemberObtainedLoan)<18 then
errmsg(..........);
endif;

I tested it for ids in the roster corresponding to the ages below and above 18 and got an error msg below

lnvalid subscript : S1Q4A(0)----var s7q3_hhids postproc

Is there anything I did wrong
Josh, I also forgot to add that there is possibity that the same ID could obtain more than one loan. meaning that the same ID can be entered more than once.
gbos
Posts: 51
Joined: June 18th, 2015, 7:49 pm

Re: Problems with SEEK AND SELECT ERROR MSG FUNCTIONS!! Urg

Post by gbos »

Thanks, Josh. I am sorry. It worked. pls ignore my first reply. initially, I did not specify the correct variable s7aq3_hhids. that was the the problem. thanks once again and apology. :D
Post Reply