Numeric fields as an index can lead problems if typing is not in sync. It also makes it more difficult to build complex (multi-field) keys, for example Lot number + Expiration Date. There are good reasons to use character fields left padded with zeros - there is very little room left for confusion. And, there is the benefit of combining fields for multiple firld keys.
if the contents of lotno were "000006", then you could:
if SEEK(RIGHT(STR(mhlotno+1000000,7),6),"lotno","lotno")
MESSAGEBOX("This Lotno already exists",0,-1,"New Lot Entry")
thisform.text2.SETfocus
ELSE
MESSAGEBOX("Woo Hoo New Lot made",0,-1,"New Lot Entry")
APPEND BLANK
replace lotno WITH mhlotno
thisform.text2.SETfocus
ENDIF
One question: If the user makes a mistake on the lot number (transposition error), do they have to delete the erroneous lot record? PS, I am sure there are easier ways to left pad with zeros.
>I am getting a program error "uniqueness of index is violated"
>
>I am using a simple form with two text boxes, text1 control source is
> variable mhlotno, numerical, format 666666
>
>Lotno is a table, with one field,named lotno, numerical,width of 6 and with a candidate cdx index named lotno
>
>here is my script:
>
>under gotfocus procedure for text1
>mhlotno=0
>
>under lostfocus procedusre for text1
>SELECT lotno
>SET ORDER to lotno
>
>SEEK mhlotno
>IF FOUND()
> MESSAGEBOX("This Lotno already exists",0,-1,"New Lot Entry")
>thisform.text2.SETfocus
>
>ELSE
> MESSAGEBOX("Woo Hoo New Lot made",0,-1,"New Lot Entry")
>APPEND BLANK
>replace lotno WITH mhlotno
>thisform.text2.SETfocus
>ENDIF
Imagination is more important than knowledge