key down usage on form

  • Thread starter Thread starter seeker
  • Start date Start date
S

seeker

I have noticed that forms have a key down event just like text boxes yet when
i put code in the event it does not work. for instance

if keycode = vbkeyreturn then
docmd.close "frmMyForm"
end if

does not close the form when I am anywhere on the form. If I put the same
code in a textbox and if I am in the textbox and hit enter then the form
closes. How does key down initiate on forms.
 
On Tue, 6 Oct 2009 20:04:01 -0700, seeker

From the help file:
the object with the focus receives all keystrokes. A form can have the
focus only if it has no controls or all its visible controls are
disabled. A form will also receive all keyboard events, even those
that occur for controls, if you set the KeyPreview property of the
form to Yes.

-Tom.
Microsoft Access MVP
 
Back
Top