Page 1 of 1

Automatic calculation (auto fill function ?)

Posted: September 11th, 2011, 5:30 pm
by Guest
Hello,

I need some help with automatic calculation.

I created a form with multiple record, one of the record is set to have max 3 occurrences.

In the record with max 3 occurrences, the first field is "Year". I would like the field "Year" of occurrence 1 to be automatically filled with the content of the field "Year" which is in the first record. Then "Year of occurrence 2 to be filled with the content of the field "Year" which is in the first record + 1, etc.

Is there an auto fill function and how do I code calculation?

Sorry for my bad english and thank you for any help.

Re: Automatic calculation (auto fill function ?)

Posted: September 11th, 2011, 5:47 pm
by lls
Somehow I found my way with the code below.
I'm not sure if this is the best way to do what I need.
Could I have an advice?

Thank you

**************************************
PROC Q62_ANREF

preproc

if not Q3_3_AOUVDOS = notappl then
impute (Q62_ANREF(1),Q3_3_AOUVDOS);
endif;

if not Q11B_ETATDOS = notappl then
impute (Q62_ANREF(2),Q3_3_AOUVDOS+1);
endif;

if not Q11C_ETATDOS = notappl then
impute (Q62_ANREF(3),Q3_3_AOUVDOS+2);
endif;

Re: Automatic calculation (auto fill function ?)

Posted: September 12th, 2011, 6:42 pm
by lls
Resolved

Re: Automatic calculation (auto fill function ?)

Posted: September 22nd, 2011, 2:05 pm
by Gregory Martin
You don't need to use the impute function. That function is in CSPro for batch editing programs and I can't think of a case in which it would necessary in a data entry application.

I do not completely understand your code, but it sounds like you could accomplish what you want to by writing something like this:
PROC Q62_ANREF

preproc

    
if Q3_3_AOUVDOS <> notappl then
        Q62_ANREF(
1) = Q3_3_AOUVDOS;
        Q62_ANREF(
2) = Q3_3_AOUVDOS + 1;
        Q62_ANREF(
3) = Q3_3_AOUVDOS + 2;
    
endif;

Re: Automatic calculation (auto fill function ?)

Posted: September 23rd, 2011, 8:50 am
by lls
This is indeed much better.

Thank you.