Enter key

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

--
 
A

Allen Browne

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.
 
R

Richard

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.
 
R

Richard

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
 
M

May

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
 
J

Jacob

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.
 
R

Richard

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top