Re: Simple KeyPress Help



Here is one way of doing it.

First, set form => keypreview => true

this means that the form handles the keypress before other objects.
Then use

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)

If you want control over which control gets what key.

With Me.ActiveControl
If .Name = "Command1" Then
Select Case KeyCode

.



Relevant Pages

  • Re: Open form with Enter key???
    ... code from the KeyPress_Event BUT hade the Locked propertie set for the ... > Every Access control has a KeyPress event. ... > Private Sub txtMyTextBox_KeyPress ...
    (microsoft.public.access.formscoding)
  • Multiple Control Event Classes
    ... I have set up a form with sixty textbox controls on it to allow the user ... AfterUpdate event procedures for each control, ... one event for each control, i.e. AfterUpdate, KeyPress and Enter. ... Private Sub TBDGroup_AfterUpdate ...
    (microsoft.public.excel.programming)
  • Re: on KEYDOWN ON SET FOCUS
    ... Private Sub Text0_KeyDown(KeyCode As Integer, Shift As Integer) ... To check the Control or Alternate key, ... >> Vanderghast, Access MVP ...
    (microsoft.public.access.forms)
  • RE: Special Effect annoying reset delay
    ... Reset it in the mouse move event of the other control. ... Private Sub imgRefresh_MouseMove(Button As Integer, Shift As Integer, X As ...
    (microsoft.public.access.formscoding)
  • Re: Open form with Enter key???
    ... KeyPress event. ... control is locked but not when it is disabled - as you cant get into it ... Shift is used to determin if any of the special keys were ... Private Sub txtTest_KeyDown ...
    (microsoft.public.access.formscoding)