Stop duplicate multiple field

Discussions about CSEntry
Post Reply
rameshpal99

Stop duplicate multiple field

Post by rameshpal99 »

Dear Sir/Ma'm,

It seems that it works only if the numeric field is entered same code in next occurance.

I would like to use this numeric field stop same code in occurance field. How can I do that?

Thank you
Gregory Martin
Posts: 1845
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Stop duplicate multiple field

Post by Gregory Martin »

You can do this either using the seek function, or by looping through your records. First, the easy way, using the seek function. The seek function returns the first occurrence of a given search query:
PROC VALUE1

    
numeric searchValue = VALUE1;
    
numeric valuePosition = seek(VALUE1 = searchValue);
    
    
if valuePosition < curocc() then
        
errmsg("You have already entered %d at occurrence number #%d",VALUE1,valuePosition);
        
reenter;
    
endif;
Alternatively, you can loop through each occurrence of the record:
PROC VALUE2

    
numeric idx;
    
    
do idx = 1 while idx < curocc()
    
        
if VALUE2(idx) = VALUE2 then
            
errmsg("You have already entered %d at occurrence number #%d",VALUE2,idx);
            
reenter;
        
endif;
    
    
enddo;
See attached for an application that demonstrates both methods.
Attachments
noDups.zip
(2.46 KiB) Downloaded 383 times
Post Reply