View Full Version : KeyPress


kev
01-01-2001, 08:05 AM
I'm Looking to get the
esc key to close the form,
and F2 to restore all minimized forms
does anyone have any idea of code needed and where to put it

cheers Kev

ElsVanMiert
01-01-2001, 09:47 AM
If you want to use the same keys throughout your application, you need to use the AutoKeys-Macro (with the AutoExec-Macro all you need to know about Macros).

The technique is as follows:
Write {F2} for the F2-key, {ESC} for escape-key

EXECUTECODE
SubAutokeys("F2")
SubAutokeys("ESC")

Then, write a sub or function "SubAutokeys" in the following style:

Public sub SubAutoKeys(strKey as string)

select case strKey
case "F2"
'Code to Restore your forms
case "ESC"
docmd.close acform,screen.activeform.name
end select

end sub

I think that "{ESC}" represents the ESC-key, but you should verify in the online-help.