so how to use function key to click my Edit Button instead of using mouse ?If I understand what you want to do correctly, All you need to do is specifiy a hot key for your edit button like this in its caption: "\
+ "E", it wil be the same as if they have clicked the edit button.
If you must use the F2 key instead, it is a bad idea to use an OKL. An OKL unconditionally interrupts whatever code is running and you have no control over it. Instead, step the form's KeyPreview proerty to true and in the form's KeyPress method, put this code:IF nKeyCode = -1
ThisForm.MyEditMethod()
ENDIF
I would suggest that the code in your Edit button's click method also be the same as this line, that is: ThisForm.MyEditMethod(). All the code needed from both the button click and the press of the F2 key should go into that custom form method.