>LPARAMETERS tnKeyCode >*** First check to see if we have a key that we can handle >*** A 'printable' character, backspace or <DEL> are good candidates >IF BETWEEN( tnKeyCode, 32, 128 ) OR tnKeyCode = 7 > WITH This > *** First check to see if we have timed out > *** and reset the search string if we have > IF DATETIME() - .tLastPress > .nTimeOut > .cSearchString = '' > ENDIF > *** So now handle the key > DO CASE > CASE tnKeyCode = 7 > *** If the delete key was pressed, reset the search string > *** and exit stage left > .cSearchString = '' > RETURN .T. > CASE tnKeyCode = 127 > *** Backspace: Remove the last character from the Search string > IF LEN( .cSearchString ) > 1 > .cSearchString = LEFT( .cSearchString, LEN( .cSearchString ) - 1 ) > ELSE > .cSearchString = '' > RETURN .T. > ENDIF > OTHERWISE > *** A garden variety printable character > *** add it to the search string > .cSearchString = .cSearchString + CHR( tnKeyCode ) > ENDCASE > *** Search for the closest match in the grid's record source > .Search() > *** Update value for keyPress interval timer > .tLastPress = DATETIME() > ENDWITH >ELSE > *** Not a key we can handle > *** Let VFP handle it by default > This.cSearchString = '' > RETURN .F. >ENDIF >>
>LOCAL lnSelect, lnCurRec, lcAlias > >*** Save Current work area >lnSelect = SELECT() > >*** Get the grid's RecordSource >lcAlias = This.Parent.Parent.RecordSource > >Thisform.LockScreen = .T. > >*** Search for the closes match to the Search string >WITH This > *** Save the current record > lnCurRec = RECNO( lcAlias ) > IF NOT EMPTY( .cTag ) > *** Use an index tag if one exists > IF SEEK( UPPER( .cSearchString ), lcAlias, .cTag ) > *** Do nothing...we found a record > ELSE > *** Restore the record pointer > GO lnCurRec IN ( lcAlias ) > ENDIF > ELSE > *** No Tag...have to use LOCATE > SELECT ( lcAlias ) > LOCATE FOR UPPER( EVAL( JUSTEXT( .Columns[ 1 ].ControlSource ) ) ) = ; > UPPER( .cSearchString ) > IF NOT FOUND() > GO lnCurRec > ENDIF > SELECT ( lnSelect ) > ENDIF >ENDWITH > >Thisform.LockScreen = .F. >