[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How do I cancel a Keystroke entry

Posted on 2011-10-29
5
Medium Priority
?
198 Views
Last Modified: 2012-05-12
I have a form opened in acformadd to add a new record.  If I accidentally press Function Key 5, all the previously entered data is cleared.

How can I prevent this?

Thanks in advance..  
0
Comment
Question by:CRB1609
  • 2
  • 2
5 Comments
 
LVL 40

Assisted Solution

by:als315
als315 earned 800 total points
ID: 37049538
You should use this code:
If KeyCode = 116 Then KeyCode = 0
in KeyDown event for every editable field in your form
0
 
LVL 58

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 1200 total points
ID: 37049727

  Another way to eat up keystorkes is to add an autokeys macro, define the keystorke in it, and then do nothing.

  This disables it app wide.  Finer control can be achieved as als315 said, but note that it deosn't have to be done on every control.

  You can set the forms Keyprview to true.  The form will then receive the keystroke before any control.

  So you can do this at app level, form level, or control by control.

Jim.
0
 
LVL 40

Expert Comment

by:als315
ID: 37049823
Thanks, Jim. I always forget this opportunity.
0
 
LVL 58
ID: 37050024
<<Thanks, Jim. I always forget this opportunity. >>

  No problem.  Something like that is easy to forget when it's not something you use very often.   I also get caught on a lot of the new features in A2007/2010 because I simply don't use them and I answer with a 2000/2003 style answer.

  Frankly, I haven't used a lot of the new features added since 2000.  Pivot charts is a good one.  Then there's stuff that I've had routines to work with for years, such as printers, so I don't bother with the printer object introducted in 2003 for example.

  And of course as simple as it seems, Access really is a complex product and it is difficult to keep up with everything it has in there.

Jim.
0
 

Author Closing Comment

by:CRB1609
ID: 37050163
Thanks very much to both of you.  Hope you don't mind that I shared the points.  I worked out that you could control it at the form level, but the autokeys idea is excellent.

Thanks again.

CRB
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
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…
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.
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…
Suggested Courses

830 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