I keep getting "Invalid table number" error
This is a new one to me, any ideas?
Thanks
Stephen McLaughlin
LPARAMETERS tcAlias, tuSearchVal, tlMatchWholeField
LOCAL laFields[1], lnFieldCnt, lnField, llMatchFound, luCompVal
*** Make sure passed alias is available
IF ! USED( tcAlias )
USE ( tcAlias ) IN 0
ENDIF
*** Get the field names
lnFieldCnt = AFIELDS( laFields, tcAlias )
SELECT ( tcAlias )
*** Scan the table
SCAN
*** look for a match in each field
FOR lnField = 1 TO lnFieldCnt
luCompVal = IIF( INLIST( VARTYPE( EVAL( lafields[ lnField, 1 ] ) ), 'C', 'M' ), ALLTRIM( EVAL ( laFields[ lnField, 1 ] ) ), EVAL ( laFields[ lnField, 1 ] ) )
llMatchFound = .F.
IF tlMatchWholeField
IF tuSearchVal == luCompVal
llMatchFound = .T.
EXIT
ENDIF
ELSE
IF INLIST( VARTYPE( EVAL( lafields[ lnField, 1 ] ) ), 'C', 'M' )
IF tuSearchVal $ luCompVal
llMatchFound = .T.
EXIT
ENDIF
ENDIF
ENDIF
ENDFOR
IF llMatchFound
EXIT
ENDIF
ENDSCAN
IF llMatchFound
MESSAGEBOX( 'Match found in field: '+laFields[ lnField, 1 ]+CHR(13)+ 'Record Number '+ALLTRIM( STR( RECNO( tcAlias) ) ) )
ENDIF