Select Table1 Scan All llFound = .F. lnLen = Len(ID_Field) Do While !llFound and lnLen > 0 llFound = Seek(Substr(ID_Field,1,lnLen), "Table2", "ID_Index") If !llFound Then lnLen = lnLen - 1 Endif EndDo If llFound Then * Found a match - do some stuff here Else * no match - do some other stuff Endif EndScanThis will scan table1 and look for a match in table2 for the full 6 digit ID. If it is not found it will remove the leftmost character until a match is found or until there are no more characters to remove.