ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Setting form controls focus and enter key (https://www.excelbanter.com/excel-programming/278869-setting-form-controls-focus-enter-key.html)

John T Ingato

Setting form controls focus and enter key
 
I have a form set up for entering names into my application. On this setup
form I have a

textbox ="NameEntry and a
Listbox = "RepList"
Button1 = "add"
Button2 = "remove"

The users procedure is:

1) Enter name into text box
2) click on the add button

The name is tranfered to the listbox for viewing and the "textbox" is
cleared, but the add button remains in focus

How can I return focus to the textbox? i.e. place the cursor back into the
text box.
Is it possible to set the "enter" key to click the add button instead of
have to actually click it with the mouse?

A KeyPress event does not occur under the following conditions:

a.. Pressing TAB.
b.. Pressing ENTER.
c.. Pressing an arrow key.




Tom Ogilvy

Setting form controls focus and enter key
 
You can set the Default property of the add button to True. Only one
control on the form can have the default property set to true. If enter is
hit, then the click event for that control is fired.

Have you tried using the setfocus method of the control?

--
Regards,
Tom Ogilvy


"John T Ingato" wrote in message
...
I have a form set up for entering names into my application. On this

setup
form I have a

textbox ="NameEntry and a
Listbox = "RepList"
Button1 = "add"
Button2 = "remove"

The users procedure is:

1) Enter name into text box
2) click on the add button

The name is tranfered to the listbox for viewing and the "textbox" is
cleared, but the add button remains in focus

How can I return focus to the textbox? i.e. place the cursor back into

the
text box.
Is it possible to set the "enter" key to click the add button instead of
have to actually click it with the mouse?

A KeyPress event does not occur under the following conditions:

a.. Pressing TAB.
b.. Pressing ENTER.
c.. Pressing an arrow key.







All times are GMT +1. The time now is 03:43 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com