On user hit [enter] (On KeyPress)

J

James

I have a text box with a cmdButton right next to it.

So the user types their input in the box and hits enter, expecting it
to return values. Well instead, enter just moves it to the next tab
order, which is the cmd box. I understand that the on key press will
trigger this event, but it will also do it if the button as been tabbed
to. Is there any way to just specify the enter key for doing this?
Thanks!
 
R

Rick Brandt

James said:
I have a text box with a cmdButton right next to it.

So the user types their input in the box and hits enter, expecting it
to return values. Well instead, enter just moves it to the next tab
order, which is the cmd box. I understand that the on key press will
trigger this event, but it will also do it if the button as been
tabbed to. Is there any way to just specify the enter key for doing
this? Thanks!

Look at the property sheet for your button on the {Other} tab of the
property sheet. You should see a property named "Default". Set that to Yes
and your button action will run any time the user presses <Enter>.
 
J

James

Great! Thanks!

Rick said:
Look at the property sheet for your button on the {Other} tab of the
property sheet. You should see a property named "Default". Set that to Yes
and your button action will run any time the user presses <Enter>.
 
J

James

ooo... problem... there can only be one default enter on the form i
have 4 instances of a txt box followed by a cmd button.... any clue on
how to do it for 4 buttons on one form? Thanks
 
C

ChrisM

How about handling the OnKeyDown event in each text box. If the KeyCode = 13
then ENTER has been pressed, and you can act accordingly...

Cheers,
Chris.

James said:
ooo... problem... there can only be one default enter on the form i
have 4 instances of a txt box followed by a cmd button.... any clue on
how to do it for 4 buttons on one form? Thanks
 

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