Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2008-10-18
3
Medium Priority
?
957 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Suggested Courses

722 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