Enter key

  • Thread starter Thread starter Richard
  • Start date Start date
R

Richard

Hi

How do I make the form do something when I press the enter key? Now it goes
to the next field. I want it to start a command or save a record.

Thanks in advance

Richard

--
 
Place a command button on your form.
Set the button's Default property to Yes.
Whatever you want it do do when Enter is pressed, put in the command
button's Click event.
 
Thanks Allen

--


Allen Browne said:
Place a command button on your form.
Set the button's Default property to Yes.
Whatever you want it do do when Enter is pressed, put in the command
button's Click event.
 
HI Allen

I tried it but it works only if the button has the focus. How do run the
command with enter even if the focus is on other controls.

Thanks again

Richard
 
under form properties, change "key preview" = yes
then write the code you want in the event of "key press"

if keyascii = vbkeyreturn then
' put your code here
end if

May
MCP in Access and SQL Server
 
Click on the upper left of the form on the square in the
corner to select the entire form. Than right click on it
and go to properties. Then select the event tab and set
your new formula in the On Enter Field. You can set
either a macro to save or print, VB Code to do almost
anything, or event procedure using the wizard.
 
Thanks May

works like a charm

Richard

--


May said:
under form properties, change "key preview" = yes
then write the code you want in the event of "key press"

if keyascii = vbkeyreturn then
' put your code here
end if

May
MCP in Access and SQL Server
 
Back
Top