>*** 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 >ENDIF >>
>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 >ENDWITH >