Make ID item sequential

Discussions about CSEntry
Forum rules
New release: CSPro 8.0
Post Reply
Guest

Make ID item sequential

Post by Guest »

How can I make an ID item sequential (this item is not persistent).
Gregory Martin
Posts: 1777
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Make ID item sequential

Post by Gregory Martin »

There are two ways you can do this. Using logic, you can keep track of the previously-entered ID and then increment it and assign it to the current ID field. The problem with this solution is that the ID item will only be sequential within a given run of CSEntry. If you close CSEntry and open it again, then the previously-entered ID will no longer be in memory. You can code this as follows:
PROC GLOBAL

numeric prevID = notappl;


PROC ID

preproc

    
if prevID <> notappl then
        ID = prevID +
1;
        
noinput;
    
endif;

postproc

    prevID = ID;
The other way to do this, which will keep track of the previous ID across CSEntry runs, it to declare your field as persistent and then override that setting using logic. For example, to set the starting ID as 1 and then go up from there, you would write:
PROC GLOBAL


PROC SEQID_QUEST

preproc

    
if visualvalue(ID) = notappl then
        ID =
1;

    
else
        ID =
visualvalue(ID) + 1;

    
endif;


PROC ID

preproc

    
noinput;

See attached for a sample application.
Attachments
seqID.zip
(2.08 KiB) Downloaded 581 times
Post Reply