Page 1 of 1

Sequencial ID number

Posted: September 14th, 2016, 4:21 am
by rcovane
Hi everyone.

I'm trying to make the ID variable sequencial. It has 3 digit and identifies the household. The data entry will be on android.

The problem is this option is deativated on field properties window.

Thanks

Re: Sequencial ID number

Posted: September 14th, 2016, 9:02 am
by josh
ID items cannot be sequential in CSPro however there are some workarounds. This a question that has been discussed before on the forum. Here a some answers:

http://www.csprousers.org/forum/viewtop ... 277&p=3775
http://www.csprousers.org/forum/viewtop ... 920&p=2386

Searching for "sequential" in the forum will bring up more.

Re: Sequencial ID number

Posted: September 15th, 2016, 3:07 am
by rcovane
Thanks Josh,

I used this solution with some modifications:
Gregory Martin wrote:You can make your ID field both protected and persistent, and then write code like this:
PROC ID

preproc

    
if demode() = add then
    
        
if visualvalue(ID) = notappl then // this is the first case in the data file
            ID = 1;
        
        
else // this is the second, third, etc. case in the data file
            ID = visualvalue(ID) + 1;
        
        
endif;
    
    
endif;