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

x
?
Solved

Access VBA code: Pressing Esc to run code and exit the form

Posted on 2008-10-18
3
Medium Priority
?
988 Views
Last Modified: 2013-11-28
Hi,

I have a form which records via a barcode scanner products purchased for an honesty bar. In the old system after scanning the items wanted you hit the Escape key which recorded the purchases against your account and logged you out.

Do I use the "On Key Press" Event within the purchsing form and if so how do I tie the code to the pressing of the Esc key?

Thanks in adavnce.

Jon
0
Comment
Question by:itmtsn
  • 2
3 Comments
 
LVL 8

Accepted Solution

by:
Jupiler78 earned 2000 total points
ID: 22748557
Hello itmtsn,

If that is what you want, use the On Key Down on the form:
    If KeyCode = vbKeyEscape Then
        MsgBox "escape key"
        DoCmd.Close
    End If

that code captures the escape key on the form event.
Just on the form properties set on tabblad event - key preview to yes

Regards,

Jupiler78
0
 

Author Closing Comment

by:itmtsn
ID: 31507424
Thanks very much, worked a treat!
0
 
LVL 8

Expert Comment

by:Jupiler78
ID: 22755446
Glad I could help.
thanks for the points & grade.

Jupiler78
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

885 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