Solved

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

Posted on 2008-10-18
3
878 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 500 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

746 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

11 Experts available now in Live!

Get 1:1 Help Now