Pressing Enter after entry into Textbox

MsLady

Traumatized by Access
Local time
Yesterday, 23:12
Joined
Jun 14, 2004
Messages
438
I have a textbox and a command button by this textbox that performs an action based on the value in this textbox when clicked.

I want to be able to press the enter key after entry into the textbox and have it perform the same thing the command button does.

I tried Calling the commndbutton procedure from the OnEnter event from of textbox, but it tries to process as soon as i "start entering data into the textbox".
I hope i am clear? How do i achieve this, so that by pressing the enter key after entering a value in my textbox, my textbox value is processed, instead of clicking the command button.

This is just to enhance usability. Any help will be mucho appreciatied :D
 
You could try calling the procedure from either the After Update or Lost Focus property of the textbox.

Failing that, you could call it from the On Click event of the button you mentioned.
 
Matt Greatorex said:
You could try calling the procedure from either the After Update or Lost Focus property of the textbox.

Failing that, you could call it from the On Click event of the button you mentioned.

That does it!! :)
Thanks Matt
 
That method assumes you want the command to run every time you enter data into the text box.

Or, you can set the command button's "Default" property to Yes. Doing this means that when the user press's enter, its the same as clicking on this button. Typically you'd do this for an "OK" button.
 
I think I understand, how about something like this,

In the OnEnter event of the textbox, change the Default command button to reflect the requested button like this

Code:
me.cmdButton.Default = True

This will activate the code for that button when the enter key is pressed

This way you can change the Default button for any textbox

EDIT: lol, I swore when I looked at this post it had zero replies, good luck MsLady
 

Attachments

Last edited:
Thanks guys! This is obviously a better idea.
I have this on my onEnter event now.
Code:
me.cmdQuickFind.Default = True

Thanks, Matt, ejstefl and ssteinke.
for that quick lesson :)
 
Thanks for the Tips!!!!

This code exactly works...... thanks for the tips.... Actually i am stuggling with Enter the Username and Password Problem... With the sample Below i can't scan the password when i pressing enter key after i key in the password until i press the Login Button... then u guys comes out the prefect idea of when the user press enter = Click the Login button.

Billion Thanks!!!!

Regard,
alex
 

Attachments

Users who are viewing this thread

Back
Top Bottom