Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I make *something* happen when Return key is hit

Status
Not open for further replies.

KennyUK

Technical User
Sep 13, 2001
38
0
0
GB
Hi gang,


I am using MS Access 2000 - I need to have an event happen when a user has typed data into a text box called txtCore on a form called form called frmEvents and hit the return key, for example:

User enters txtCore - types something - hits the return key - My event is triggered.

I have been reading in the help files about KeyDown, KeyUp Events and KeyPress Events together with what little info there is on Keycode Constants but as I am sure most of you know - Access help is not really as helpful as it should be especially to those of us who are not that experienced with VBA and so on.

Any help or examples would be great.

cheers,

Kenny
 
On the other tab of your text box properties sheet is a 'Enter Key Behavior' property. That might help you.

If you need to do something when the entry is finished you can look at the Before or After Update events of your text box.

If you really need to look for Enter and trigger an event you can put this in the KeyDown event

If KeyCode = 13 Then '13 = Enter
MsgBox "Enter was pressed"
End If "The Key, The Whole Key, and Nothing But The Key, So Help Me Codd!"
 
Set up a command button on your form. Attach the code you want to run to the OnClick event of the button.

In the GotFocus event of your text box put something like this:
Code:
cmdYourButtonName.Default = True
When the user types something in the text box that button becomes the default. When they hit enter, the code behind the button is run......
 
Hey guys,

Thanx for the tips, it all works fine now,

Cheers,

KennyUK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top