lcOldError = on('error') on error do RetryOpeningTable with lcTable, Error() use TableMetaData scan && scanning table that contains your table names, index keys, expressions lcTable = alltrim(TableMetaData.Table_Name) if file(addbs(PathToData) + lcTable + ".CDX") erase addbs(PathToData) + lcTable + ".CDX" endif select 0 use (lcTable) exclusive if !used(lcTable) ** do something endif ** start building indexes here use endscan use in TableMetaData on error &lcOldError return procedure RetryOpeningTable lparameter tcTable, tnErrorNum do case case tnErrorNum = 1707 if !used(tctable) use (tcTable) exclusive endif case tnErrNum = some_number && do stuff otherwise && do stuff endcase return .t.>When I erase a cdx file and try to recreate the index, I get the error message "structural .cdx not found" when I open the table and a dialog box comes up with "Cancel ...".