*** If the key pressed was a printable character or a backspace, handle the keystoke and search IF ( LASTKEY() > 31 AND LASTKEY() < 128 ) OR ( LASTKEY() = 7 ) IF This.HandleKey( nKeyCode ) NODEFAULT ENDIF ENDIFAdd a custom method called handleKey. This code in HandleKey():
LPARAMETERS tnKeyCode LOCAL lcSofar, lnSelect, lnSelStart, lnSelLength WITH THIS *** Get the value typed in so far lnSelStart = IIF( tnKeyCode # 127, .SELSTART + 1, .SELSTART - 1 ) *** On backspace, remove one character from current position *** and search IF tnKeyCode = 127 IF lnSelStart <= 0 GO BOTTOM IN ( .calias ) SKIP IN ( .calias ) .VALUE = '' RETURN ELSE lcSofar = LEFT( .VALUE, lnSelStart ) ENDIF ELSE *** Get the value typed in so far *** and add the current key stroke lcSofar = LEFT( .VALUE, .SELSTART ) + CHR( tnKeyCode ) ENDIF .VALUE = lcSofar *** Use seek to find the record if a tag was provided IF ! EMPTY( .ctag ) IF SEEK( UPPER( lcSofar ), .calias, .ctag ) .VALUE = EVAL( .calias + '.' + .cfield ) ENDIF ELSE *** Otherwise, save the current work area before swithching to the specified table lnSelect = SELECT() SELECT ( .calias ) *** And locate the specified record LOCATE FOR UPPER( ALLTRIM( EVAL (.cfield ) ) ) = UPPER( lcSofar ) IF FOUND() .VALUE = EVAL( .calias + '.' + .cfield ) ENDIF SELECT ( lnSelect ) ENDIF *** Highlight the portion of the value after the insertion point .SELSTART = lnSelStart lnSelLength = LEN( .VALUE ) - lnSelStart IF lnSelLength > 0 .SELLENGTH = lnSelLength ENDIF DOEVENTS ENDWITH