Results 1 to 2 of 2
  1. #1
    Star Lounger
    Join Date
    Oct 2003
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Right Arrow Key Press (2000)

    Trying to write a simple If/Then statement to see if the Right Arrow key has been pressed. I want to add it to the KeyPress function on my Access form using the SendKeys statement and run a set of code if the right arrow is clicked. I am not having much luck doing this. I know this has to be a simple statement but just can't get it. Any help would be appreciated.

    Private Sub List6_KeyPress(KeyAscii As Integer)

    If SendKeys "{RIGHT}", False
    'RUN UPDATE TO YES FUNCTION HERE
    Else
    'DO NOTHING
    End If

    End Sub

    Thanking you in advance I am...

    Steve

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Right Arrow Key Press (2000)

    1) The SendKeys instruction is used to let your program simulate a keystroke. It can't be used to check if a key has been pressed.

    2) The On Key Press event only occurs for printable characters, Enter and Backspace, but not if the user presses an arrow key. You can use the On Key Down or On Key Up event for that.

    For example:

    Private Sub List6_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyRight Then
    ' your code here
    ...
    End If
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •