Action from particular key press

  • Thread starter Thread starter gg
  • Start date Start date
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
 
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
 
Back
Top