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
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.