>I have this form in VFP5 that has a custom METHOD called showkeyx.
>In the INIT of the form I have this code
>
>ON KEY LABEL F2 THISFORM.showkeyx
>
>What I need to do is call this custom method when the F2 key is pressed.
>
>But when I run the form, I get an error at the INIT for the code line
>ON KEY LABEL...
>
>The only way I can get this ON KEY to work is by creating a PRG file called showmykey with the line:
>
>FORMNAME.showkeyx
>
>and in the init of the form:
>ON KEY LABEL F2 DO showmykey
>
>This works and the custom method is called.
>
>But I want to be able to call the custom method of the form, from the form itself with an ON KEY LABEL ... WITHOUT the external PRG file.
>
>Is this possible and how can I do this????
Two suggestions:
1. Change to
PUBLIC MYSCREEN
MYSCREEN = THISFORM
ON KEY LABEL =MYSCREEN.SHOWKEYX
Don't forget to RELEASE MYSCREEN, in the DEACTIVATE and UNLOAD events code.
2. A better solution: add a dynamic menu (see how in the Sample Applications) for that won't cause any problems as the OKL, which can be executed in the wrong moment.
HTH!