Virusim,
I tried this, with a form with 2 textboxes and a close button and it worked perfectly. I don't know what control you have the focus set to when you were entering your keyboard string. That may make a difference. For example, on a form with only a disabled textbox (txtdisplay) and a close button the Chr(13) displayed the data correctly but then closed the form because the focus was on the Close button (no other controls).
Let us know more about your form and what has the focus.
HTH
Barbara
>Hi,
>
>I had a form with text control. I had enable the form keypreview properties to true and had code in the keypress event of the form to check for keyboard entry. I want to display the string only on Enter key detect with the code shown below, but it didn't work.
>It can display the string enter but can't show in the text box.
>What is wrong, please advise me. Thank you
>
>FORM.KeyPress
>LPARAMETER nKeyCode, nShiftAlt
>
>NODEFAULT
>
>* if enter key detect
>IF nKeyCode = 13
> Dodefault(nKeyCode,nShiftAlt)
>
> = MessageBox('The string enter = '+THISFORM.frmBuffer)
> THISFORM.txtDisplay.Value = THISFORM.frmBuffer
>
>ELSE
>
> THISFORM.frmBuffer = THISFORM.frmBuffer+CHR(nKeyCode)
>
>ENDIF