By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,222 Members | 1,129 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,222 IT Pros & Developers. It's quick & easy.

Key-assignment

P: n/a
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
Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyF5 Then
Me.ActiveControl = Me.ActiveControl.Text & " " & Now()
'Without this next line, the control's entire contents was highlighted
'making it hard to continue typing in the control
Me.ActiveControl.SelStart = Len(Me.ActiveControl.Text)
KeyCode = 0
End If
End Sub

--
Wayne Morgan
Microsoft Access MVP
"Trade STAR Inc" <es******@tradestarinc.com> wrote in message
news:de**************************@posting.google.c om...
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

Nov 13 '05 #2

P: n/a
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.
" <es******@tradestarinc.com> wrote in message
news:de**************************@posting.google.c om...
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

Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.