Page 1 of 1
Stop duplicate multiple field
Posted: December 6th, 2012, 12:30 am
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
Re: Stop duplicate multiple field
Posted: December 7th, 2012, 12:29 pm
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.