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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Keypress event

Status
Not open for further replies.

Digsys

Technical User
Joined
Jun 27, 2002
Messages
170
Location
AU
I have a form based on a recordset and when I leave a control I want to update the record. At present I do this on the EXIT event, but this produces problems so I would rather use the keypress event and check for the ENTER key being pressed. I just dont know where to look to find out how to code this. Can any one help???
 
Hi!

Don't think the keypress event would suffice, think keydown is better (don't know why, but keypress don't seem to capture enter when other characthers arent entered)
If you use it on a control:

[tt]private sub txtSomeControl_KeyDown(KeyCode as integer, Shift as Integer)
if keycode=vbkeyreturn then
' some code me.refresh, me.requery, docmd.runcommand accmdsaverecord
end if
end sub[/tt]

sure you wanna do this? what if the user presses tab? or the user "browses thru" the control using arrow keys...

Have you tried using the After Update event for your current code?

If any of this didn't give you the solution you want, consider elaborating a bit more about what you want to achieve.

HTH Roy-Vidar
 
Thanks Roy. That is exactly what I wanted. The keydown does the trick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top