Action from particular key press

G

gg

I would like to perform a simple procedure when a user
presses the space bar. (much easier to press space bar
than "enter" or f key on a bobbing boat). . Keydown is
too general as there are reasons to press other keys. How
do I sense that the spacebar was the one keyed down?

Thanks in advance
 
L

Larry Linson

gg said:
I would like to perform a simple procedure when a user
presses the space bar. (much easier to press space bar
than "enter" or f key on a bobbing boat). . Keydown is
too general as there are reasons to press other keys. How
do I sense that the spacebar was the one keyed down?

Private Sub txtSomeControl_KeyPress(KeyAscii As Integer)
if KeyAscii = Asc(" ") then
... perform your procedure
end if
End Sub

Note that this is in the KeyPress event of a particular control... there is
also a KeyPress event for the Form itself. Give both a try to see which you
really want to use.

Larry Linson
Microsoft Access MVP
 

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