Assigning Macros to Function Keys

  • Thread starter Thread starter Tony
  • Start date Start date
T

Tony

Hello,

Does anyone know how or where to start by assigning Text
values to Function Keys (i.e. F2 = Red, F3 = Blue F4 =
Green, etc)

Thanks for any suggestions!

Tony
 
A macro named AutoKeys assigns actions to the function keys.

1. Create or open a macro.

2. In the Macro Name column (View menu if you don't see it), enter:
{F3}

3. In the Action column, choose:
MsgBox

4. Save the macro with the name AutoKeys.

Now pressing the F3 key opens a message box dialog.
 
Tony,

I assume you mean that you want the word Red or Blue or... inserted into
a textbox when you press the F2 or F3 or... key. Is this the correct
interpretation of your question? If so, this would be difficult with a
macro*, but you could use a vba procedure on the On Key Down event of
the textbox, something like this...

Private Sub YourControl_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyF2
KeyCode = 0
Me.YourControl = "Red"
Case vbKeyF3
KeyCode = 0
Me.YourControl = "Blue"
Case vbKeyF4
KeyCode = 0
Me.YourControl = "Green"
End Select
End Sub

* well, you could use an AutoKeys macro, but this would require the use
of the SendKeys macro action, which is generally not recommended :-)
 
Start by reading up on the AutoKeys macro in help.

--

Sco

M.L. "Sco" Scofield, MCSD, MCP, MSS, Access MVP, A+
Useful Metric Conversion #16 of 19: 2 monograms = 1 diagram
Miscellaneous Access and VB "stuff" at www.ScoBiz.com
 
Back
Top