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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SendKeys in Access 97

Status
Not open for further replies.

Arden

Instructor
Aug 24, 2001
31
CA
I want to be able to 'filter by form' and when the user presses {enter} the 'apply filter' command happens. I have tried sendkeys, and autokeys, but it will not let me use the enter key. Can anyone help?
 
I am assuming you will not be using the enter key for anything else.

Generally the enter key has the default action of tabbing. Microsoft Access uses the result specified under Move After Enter on the Keyboard tab of the Options dialog box, available by clicking Options on the Tools menu.

Now that we have that out of the way, here is how you can get the enter key to perform certain actions at the form level.

1. Go to the design view of your form.
2. Open the Properties window for the form.
3. Go to the events tab.
4. Set Key Preview to Yes. This will tell access to evaluate key strokes at the form level before they evaluate them at the control level.
5. Now in the form's On Key Press event put this...

Private Sub Form_KeyPress(KeyAscii As Integer)

If KeyAscii = vbKeyReturn Then
'Do something right here
End If

End Sub

Good luck.
ljprodev@yahoo.com
ProDev, MS Access Applications B-)
 
ANOTHER way is to put a filter by form button on the form itself, and set the button itself to be the default form button. Then when the user presses ENTER that button gets automatically selected/pressed.
Joe Miller
joe.miller@flotech.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top