Link to home
Start Free TrialLog in
Avatar of anthonytr
anthonytrFlag for United Kingdom of Great Britain and Northern Ireland

asked on

On Enter go to next available field on form

Hi,

I have a form with 6 reference fields.  A user can click a checkbox next to each field to enable that field.  To make data entry easier, I am trying to code the following:

On the Enter key being pressed, move to the next available (enabled) field out of the 6 Reference Fields.  If only the first 3 fields are enabled, hitting enter after entering information in the first field will move to Reference 2, after hitting enter, move to Reference 3, after hitting enter it would now ADD the record to the table and move to Reference 1 to start all over again.

Thanks,
Anthony
ASKER CERTIFIED SOLUTION
Avatar of Dale Fye
Dale Fye
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of crystal (strive4peace) - Microsoft MVP, Access
crystal (strive4peace) - Microsoft MVP, Access

hi Anthony,

In addition to Dale's advice, you can make the ENTER key behave like the TAB key using the default settings, which do not get saved with the current Database, it is for each machine.

File > Options >  Client Settings > Move after enter

there are 3 choices:
- don't move
- next field --> this is the one you want
- next record

have an awesome day,
crystal
The behavior you're describing is very close to what Access does by default - moving to the next enabled tab stop when the enter key is hit, and moving to the next record when the Enter Key is hit from the last tab stop.  (Just make sure you haven't set the Enter Key Behavior property of any of the textboxes to 'New Line In Field').

>> after hitting enter it would now ADD the record to the table and move to Reference 1 to start all over again.

Additionally, if you only are concerned with entering NEW records, set the Data Entry property of the form to YES.
The tab key and enter key have meaning.  Why change their behavior?  Tab goes field to field, enter goes to the next row (record).  That's the way it has worked since typewriters were invented.  People who know how to touch type expect that behavior.

Dale gave you one solution for enabling fields by using the tab stop.  You could also use the enabled property of a control to cause the tab to skip over the field.

Consistency is the key to all good interface designs.
Avatar of anthonytr

ASKER

Hi,

Thanks for the input.  I am using the TAB stop method already.  I should have mentioned that the form is unbound and the fields in question are related to a subform within the main form.  So, when the last field is reached (in the active fields) i need to ADD the data to another table with an "strSQL = "INSERT INTO" statement.
Just out of interest, why are you using an unbound form; one of the greatest strengths of Access is that you can bind data to forms so easily.
Hi,

I normally do use bound forms, however my BE is MSSQL and the main database will be used by multiple people.  I always seem to run into issues when using bound forms, MSSQL and multi users.
Curious what problems you are running into?  We have several databases here with SQL Back-Ends, and no issues with 200+ users.

<<So, when the last field is reached (in the active fields) i need to ADD the data to another table with an "strSQL = "INSERT INTO" statement. >>

Anyhow, you can try coding the Exit event of your last textbox to run the INSERT statement.
I always seem to run into issues when using bound forms, MSSQL and multi users.
Rather than abandoning the strength of Access, you should figure out what you are doing wrong.

I've been using linked tables and bound forms since the early 90's against SQL Server,Oracle, DB2, and Sybase to name a few RDBMS's.  Some of my apps can easily have over a hundred concurrent users.