Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Assign keystroke to button on Form

Posted on 2002-04-19
3
Medium Priority
?
381 Views
Last Modified: 2006-11-17
Can you show me how to assign a keystroke to a button on a Form.

I have a Form with a command button that checks the data on the Form and then moves to the next record if check is OK.

I want to assign the key F5 (for instance) to carry out the command button's function, ie if the user presses F5 then the data should be checked and move to the next record.

Thanks.
0
Comment
Question by:naqayya
  • 2
3 Comments
 
LVL 44

Accepted Solution

by:
bruintje earned 400 total points
ID: 6953116
Hi nagayya,

You could do something like

if your buttonclick code is something like

Private Sub Command0_DblClick(Cancel As Integer)
  MsgBox "hello!"
End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
  If KeyCode = vbKeyF5 Then ' call the buttonclick code
    Call Command0_DblClick
  End If
end sub

HTH:O)Bruintje
0
 

Author Comment

by:naqayya
ID: 6953251
Great! But have to set Key Preview to 'Yes'

Thanks!
0
 
LVL 44

Expert Comment

by:bruintje
ID: 6953275
yeah sorry forgot to add that

thanks for the grade
:O)Bruintje
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
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…

971 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