Run command on enter push

R

Ryan Tisserand

I dont know if im not looking in the correct areas, but I cant seem to find
the answer to my question. All I want is to run a command when the enter key
on the keyboard is pushed. I have a form with two fields and a button. User
name, and password are the fields. Login is the button. I would like the
login button event to happen if the user pushes enter on the keyboard while
on the password field. Is this possible?
 
M

Mr B

Ryan,

First I would suggest that you make sure that you have set the Tab Order for
the controls on your form. This will insure that your users are navigating
throught the options on your form in the way that you want them to. Doing
this may solve your issue altogether because when the user enters their User
Name and presses the enter key they will be moved to the Password field.
Like wise when they have entered their password and pressed the enter key,
the focus would be passed to the Login button and user could just press the
Enter key again and the code assigned to the OnClick event of the Login
button would be run.

Now, to answer your question; I assume that want you are wanting to do is
to fix your form so that the user does not have to click the Login button
with the mouse because pressing the enter key is actully an indication to any
control that you have finished your entry into that control. You can set the
Login button to be the default button by setting the Default property of the
Login button to Yes. However, be aware that this is really designed to be
used when you have multiple buttons on one form.
 
R

Ryan Tisserand

Thank you for your quick response. This did solve my issue. I knew it
should be something easy and I have been racking my brain for a week on this
one. I have at least 150 forms to go back and add this to beacuse everyone
complains that they have to hit enter 2 times to do anything.
 
M

Mr B

Glad to help. That is what this community is all about. I've used it many,
many times and really don't know what I would have done without it.

Good luck with your projects.

Mr B
askdoctoraccess dot com
 

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