• Key Strokes and Functions (Access 2k sr1)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Key Strokes and Functions (Access 2k sr1)

    Author
    Topic
    #379090

    Is it possible to attach a sub or function to a set of Key Strokes (Ctrl d for example)? I have a sub that inserts today’s date into controls on double-clicking and I thought it would be useful to be able to use key combinations too.
    Peter

    Viewing 1 reply thread
    Author
    Replies
    • #629977

      What’s wrong with using Ctrl + ; to insert today’s date? shrug

    • #629985

      FYI, there is already a short-cut keystroke that inserts the current date – CTRL + ;
      It is also possible to assign new short-cut keystrokes with the AutoKeys macro, but you may well be wiping out standard short-cuts that people expect to work based on experience in other databases.

      • #630015

        Steve and Wendell
        Thanks for the quick reponse. I know quite a few kb shortcuts but not that one (how embarrassing). Still that was a minor part of the question. I’ve tried various actions to work a kb shortcut using Keyup, keydown etc but I can’t seem to get it absolutely right. I’ve been able to get it from one key but not a combination which of course is what’s required.
        Peter

        • #630046

          Peter,

          Here is how I would capture a Ctrl+D in a textbox.

          Private Sub Text0_KeyDown(KeyCode As Integer, Shift As Integer)
           
          Dim CtrlDown As Boolean
           
          'Determine if the Ctrl key was pressed
          CtrlDown = (Shift And acCtrlMask) > 0
           
          'Check to see if CTRL+D was pressed
          If CtrlDown = True And KeyCode = vbKeyD Then
            'Insert the current Date into the textbox
            Text0.Text = Date
          End If
           
          End Sub

          This is the KeyDown event of the particular textbox.

          You can also capture this at the form level, by placing the text into the KeyDown event of the form AND setting the Key Preview setting to Yes.

    Viewing 1 reply thread
    Reply To: Key Strokes and Functions (Access 2k sr1)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: