Key-assignment

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Trade STAR Inc

    Key-assignment

    I want to able able to assign a function key with the Now() function.
    So, if I am in a text box or memo field all I have to do is hit F? and
    it will print the current time and date.

    Thanks,
    Eric
  • Wayne Morgan

    #2
    Re: Key-assignment

    You could try something like this. You could also add a Shift, Alt, or Ctrl
    to it if you wish. First, set KeyPreview for the form to Yes (Events tab of
    the Properties sheet) then in the form's KeyDown event:

    Private Sub Form_KeyDown(Ke yCode As Integer, Shift As Integer)
    If KeyCode = vbKeyF5 Then
    Me.ActiveContro l = Me.ActiveContro l.Text & " " & Now()
    'Without this next line, the control's entire contents was highlighted
    'making it hard to continue typing in the control
    Me.ActiveContro l.SelStart = Len(Me.ActiveCo ntrol.Text)
    KeyCode = 0
    End If
    End Sub

    --
    Wayne Morgan
    Microsoft Access MVP


    "Trade STAR Inc" <eserrell@trade starinc.com> wrote in message
    news:debbafad.0 408170836.5d1f1 f4e@posting.goo gle.com...[color=blue]
    >I want to able able to assign a function key with the Now() function.
    > So, if I am in a text box or memo field all I have to do is hit F? and
    > it will print the current time and date.
    >
    > Thanks,
    > Eric[/color]


    Comment

    • Big Time

      #3
      Re: Key-assignment

      The easiest way is to just use a macro. Create a macro, in the Macro Name
      field (you may have to unhide this column) call it {F2} or whichever
      function key you want, in the Action field use the SendKeys action, in the
      keystrokes area down below type =Now(). Save the macro and it should work
      every time you use the F2 button when you click on a field.


      " <eserrell@trade starinc.com> wrote in message
      news:debbafad.0 408170836.5d1f1 f4e@posting.goo gle.com...[color=blue]
      > I want to able able to assign a function key with the Now() function.
      > So, if I am in a text box or memo field all I have to do is hit F? and
      > it will print the current time and date.
      >
      > Thanks,
      > Eric[/color]


      Comment

      Working...