inserting cases and the totocc() function

Discussions about CSEntry
Forum rules
New release: CSPro 8.0
Post Reply
AriSilva
Posts: 591
Joined: July 22nd, 2016, 3:55 pm

inserting cases and the totocc() function

Post by AriSilva »

Hi folks,
I have a csentry application that creates a questionnaire with a single person occurrence, and then sends it to another csentry application. The second application, needing to have more than one person, inserts an occurrence for each person that needs to receive values.
After dealing with this block, I have another form that should loop thru all the persons in the questionnaire, but at that time the totocc() = 1 and the loop is executed always for the first person.
When saving (or finishing the questionnaire) and looking it at the dataviewer it has all the persons I inserted!!
What am I doing wrong? How can I force Csentry to update the totocc when inserting records?
Best
Ari
Best
Ari
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: inserting cases and the totocc() function

Post by josh »

If you are on a form AFTER the your roster then this should work. If you are doing from a field in the roster then you may not get the correct total since not all of the roster is on path (colored green). Sometimes count() works when totocc() is not giving the correct number so you might try that.

Feel free to post or send us an app that illustrates the problem and we can take a look.
AriSilva
Posts: 591
Joined: July 22nd, 2016, 3:55 pm

Re: inserting cases and the totocc() function

Post by AriSilva »

I´ll try to simplify the application as much as possible, and I´ll send it to you, with a step-by-step on how to proceed.
Best
Ari
Best
Ari
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: inserting cases and the totocc() function

Post by josh »

Sounds good. Make sure to send it to cspro@lists.census.gov. I'm out of the office starting tomorrow.
AriSilva
Posts: 591
Joined: July 22nd, 2016, 3:55 pm

Re: inserting cases and the totocc() function

Post by AriSilva »

Hi,
I have attached the application that should show the trouble I´m having here.
The pack has a totocc.docx that have a step by step that you should follow.
I hope the example works, I´ve tried it here, but...
Best
Ari
Attachments
TOTOCC.rar
(113.14 KiB) Downloaded 202 times
Best
Ari
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: inserting cases and the totocc() function

Post by josh »

Thanks for the app. I can reproduce the problem. I believe the issue is that when you call curocc() and totocc() you are no longer on the D_MORADORES_FORM. At that point you have moved to the next form, D1_RENDA_IDOSOS_FORM. Since you are not passing an argument to curocc() and totocc() it assumes you want the values for the current group which is D1_RENDA_IDOSOS_FORMand has only one occurrence. If instead you pass D_MORADORES_FORM to to totocc and curocc you will get the correct answer:
errmsg("D01_TRABALHO cur=%d numPessoa %d tot=%d totocc=%d", curocc(D_MORADORES_FORM), numPessoa, x06_total_pessoas, totocc(D_MORADORES_FORM));  //debugging
This may seem strange since both D1_RENDA_IDOSOS_FORMand D_MORADORES_FORM have fields from the D_MORADORES record in the dictionary so you might think they should have the same number of total occurrences. However, CSPro keeps a separate count of the occurrences in the dictionary record from the occurrences of each group based on that dictionary record. So if you have a case like this where there are two groups coming from the same record you can get different results from totocc() of the first group (D_MORADORES_FORM) and totocc of the second group (D1_RENDA_IDOSOS_FORM). DataViewer doesn't know about the forms and groups, it looks only at the dictionary so it shows the number of occurrences of the record D_MORADORES which will always be the same as the total occurrences of the largest group containing fields from that record. You would get the same result calling count on the dictionary record, count(D_MORADORES). This means that in your application, you will also need to insert records in the second group, D1_RENDA_IDOSOS_FORM to match the occurrences in the first form.
AriSilva
Posts: 591
Joined: July 22nd, 2016, 3:55 pm

Re: inserting cases and the totocc() function

Post by AriSilva »

That´s very interesting.
So, what you are saying is that I have to insert a "record" into every form of the application (the real application has many forms, I just sent you a snipet of it), even though the fields belong to the same single real record?
Is that correct?
I would never really thought doing that.
I´ll try it .
Thanks very much for your help.
Best
Ari
Best
Ari
AriSilva
Posts: 591
Joined: July 22nd, 2016, 3:55 pm

Re: inserting cases and the totocc() function

Post by AriSilva »

It works!.
Inserting all the record forms, even if they belong to the same real record.
Thank you again.
Best
Ari
Best
Ari
Post Reply