Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Autokeys in VB? 1

Status
Not open for further replies.

Ed2020

Programmer
Nov 12, 2001
1,899
0
0
GB
I am not a big fan of Access macros, and try to avoid using them wherever possible.

Is there any way of replicating an AutoKeys macro in VBA, or do I *have* to use a macro to do this?

TIA,

Ed Metcalfe.

Please do not feed the trolls.....
 
Yes, you can use VBA to create autokeys. You must trap the keystrokes. First, set the Key Preview property of your form to "Yes". Then create an event procedure for the Key Down event of your form. It should end up looking something like this:

Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyN And (Shift And acCtrlMask) Then
    DoCmd.GoToRecord , , acNewRec
End If
End Sub

This bit of code traps the <Ctrl><n> keystroke and automatically moves the form to a new record.

HTH...

Ken S.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top