Results 1 to 3 of 3
  1. #1
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Keyboard Shortcut Code for Alt + D Keys? (A2k (9.0.3821) SR-1)

    The following code opens the form as soon as the Alt Key is pressed on a date field.

    I need the proper code to open frmCalendar only when operator holds the Alt Key down and presses the D Key

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

    If KeyCode = vbKeyD And Shift = acAltMask Then
    DoCmd.OpenForm "frmCalender"
    End If

    End Sub

    Any clues?

    Thanks, John

  2. #2
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Keyboard Shortcut Code for Alt + D Keys? (A2k (9.0.3821) SR-1)

    I haven't tested this, but from Help I think you do this:
    <pre>Dim intAltDown As Integer
    ' Use bit masks to determine which key was pressed.

    intAltDown = (Shift And acAltMask) > 0

    If intAltDown Then
    If KeyCode = vbKeyD Then
    DoCmd.OpenForm "frmCalender"
    End If
    End if
    </pre>

    Oops. Having now tested it, I found my typo above and fixed it.
    Regards
    John



  3. #3
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Keyboard Shortcut Code for Alt + D Keys? (A2k (9.0.3821) SR-1)

    Hi John

    This is great stuff!

    Thanks, John

Posting Permissions

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