Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 2 / April 2008

Tip: Looking for answers? Try searching our database.

Cannot Stop Enter Key From Creating Record

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
EarlCPhillips - 10 Sep 2007 17:14 GMT
I have an application that evaluates the results of nutrition classes given
to needy people of all ages on how to prepare nutritious meals from the food
received from Harvesters.  There are three option groups, three text boxes
and a check box for permission to use their name.

In an effort to insist on accurate data, the user is supposed to click on an
"Add Record" button which uses the Click event procedure and VBA to check the
accuracy of entries.  I have added the following code to the Form keypress
event to try to prevent the enter key from being functional at all:

Private Sub Form_KeyPress(KeyAscii As Integer)
On Error GoTo Err_Form_KeyPress
   If KeyAscii = vbKeyReturn Then
     KeyAscii = 0
   End If
Exit_Form_KeyPress:
   Exit Sub
Err_Form_KeyPress:
   MsgBox "Error: " & Err.Description & " (" & Err.Number & ")"
   Resume Exit_Form_KeyPress
End Sub

This seems to work as long as the tab stop is less than the last piece of
data.  However, once all entries have been completed, pressing the enter key
creates the record but does not necessarily process the edits in the Add
Record button Click event.

Why does the code seem to work part of the time?  I think it is because the
tab function progressively moves execution from one tab stop to next each
time the enter key is pressed as it does in Windows.  When it arrives at the
"Add Record" button, it executes the code beneith and progresses to the next
tab stop.  This does not seem to stop it from occasionally creating an
inaccurate or blank record.  Any ideas would be appreciated on how to stop
the enter key from functioning at all on this form.

EarlCPhillips
Ex-Mainframer Learning Access To Help Feed
the Hungry Through Harvesters Food Bank
Signature

Trying To Feed The Hungry

SteveM - 10 Sep 2007 18:12 GMT
Is your form's Cycle property set to 'All Records'?
Try changing it to 'Current Record' - that will stop the user from being
able to tab out of the current record.

Steve

> I have an application that evaluates the results of nutrition classes given
> to needy people of all ages on how to prepare nutritious meals from the food
[quoted text clipped - 34 lines]
> Ex-Mainframer Learning Access To Help Feed
> the Hungry Through Harvesters Food Bank
EarlCPhillips - 10 Sep 2007 19:58 GMT
SteveM; Your suggestion seems to work.  You have helped us feed the hungry
and teach them how to prepare nutritious and healthy meals.  We can keep
track of our effectiveness.  Thanks for your input as it taught me another of
Access's secrets.

EarlCPhillips
Ex-Mainframer Learning Access To Help Feed
the Hungry Through Harvesters Food Bank
Signature

Trying To Feed The Hungry

> Is your form's Cycle property set to 'All Records'?
> Try changing it to 'Current Record' - that will stop the user from being
[quoted text clipped - 40 lines]
> > Ex-Mainframer Learning Access To Help Feed
> > the Hungry Through Harvesters Food Bank
EarlCPhillips - 10 Sep 2007 20:50 GMT
Another detail is to set all non-data controls to Tab Stop=no and Tab Index
to progressively higher numbers.  If not, it seems to interfere with stopping
the Enter key from working normally and creating a record when not intended.

EarlCPhillips
Ex-Mainframer Learning Access To Help Feed
the Hungry Through Harvesters Food Bank
Signature

Trying To Feed The Hungry

> SteveM; Your suggestion seems to work.  You have helped us feed the hungry
> and teach them how to prepare nutritious and healthy meals.  We can keep
[quoted text clipped - 49 lines]
> > > Ex-Mainframer Learning Access To Help Feed
> > > the Hungry Through Harvesters Food Bank
Albert D. Kallal - 11 Sep 2007 13:25 GMT
> Another detail is to set all non-data controls to Tab Stop=no and Tab
> Index
> to progressively higher numbers.  If not, it seems to interfere with
> stopping
> the Enter key from working normally and creating a record when not
> intended.

Keep in mind that you can also set the "enter" key as default key to fire a
button, and the "cancel" key (esc key) to cancel on a form.

If you look at the properties sheet for a command button, you see in the
other tab, a setting for

default

If you set default = yes, then when the person hits the enter key, that
button is fired. Thus, you should as a rule teach users to use the tab key
to move through the fields..and then you an make enter key hit you
close/save button.

Quite amazing that ms-access had this feature about 15 years before the web,
but if you look today, you see a lot of web based forms work with tab to
move tot he next field..and hitting enter = save/close.

in the "other" tab, right below "default" is a cancel setting, and if you
set that to "yes", then hitting esc key will fire the button...

So, try to use tab to move to the next...and save the enter key for when
done...you can thus have a new record appear during data entry without users
having to leave the keyboard. I sure with "old" mainframe experience, you
make that effort to allow users to not have to use the keyboard, or even use
the mouse to click on some save button...just have them use the enter
key..and then they get a new record.....

Signature

Albert D. Kallal    (Access MVP)
Edmonton, Alberta Canada
pleaseNOOSpamKallal@msn.com

MILLER2000 - 19 Apr 2008 16:15 GMT
WHO EVER HEARD OF A WOMAN LOSING WEIGHT--AND ENJOYING 3 DELICIOUS MEALS AT
THE SAME TIME? I don't know about eating out, but if you are into cook book,
check out my e-mail address. http://www.jshealthyenterprises.com. The cook
book that will help you out is call. THE HEALTHY LIFE COOK BOOK

> I have an application that evaluates the results of nutrition classes given
> to needy people of all ages on how to prepare nutritious meals from the food
[quoted text clipped - 34 lines]
> Ex-Mainframer Learning Access To Help Feed
> the Hungry Through Harvesters Food Bank
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.