Solved

How to tie some vba code to a function key

Posted on 2011-09-09
1
240 Views
Last Modified: 2012-05-12
When I have the cursor in a specific text box on a specific form (and only then) I would like to be able to click F5 and run some code.  How can I do that please?
0
Comment
Question by:snyperj
1 Comment
 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 total points
ID: 36512985
You can set the KeyPreview Property of the form to true.

Then put code in the KeyDown event of your textbox, similar to:

Private Sub text0_KeyDown(KeyCode As Integer, Shift As Integer)

    if KeyCode = vbKeyF5 Then
        'put your code here

         'the reset the keycode
         KeyCode = 0
    endif

End Sub
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now