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
LVL 1
anthonytrAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dale FyeOwner, Developing Solutions LLCCommented:
You should set the TabStop property (Other tab of the Properties dialog) of all of the controls except your textboxes to false.  Set the TabStop property of the textboxes to True.  When the user checks or unchecks the checkbox associated with each textbox, reset that tabstop property based on the value of the checkbox.  Code would look something like:

Private Sub chk_Reference1_Click

    me.txt_Reference1.TabStop = me.chk_Reference1

End Sub

Open in new window

I assume that the checkboxes are not bound controls, so those checks would persist from one record to the next.

Also, in order for the form to rollover to the next form when the last Reference value is entered, you need to set the forms "Cycle" property (also on the Other tab of the Properties dialog) to "All Records"
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
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
0
mbizupCommented:
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.
0
IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

PatHartmanCommented:
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.
0
anthonytrAuthor Commented:
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.
0
Dale FyeOwner, Developing Solutions LLCCommented:
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.
0
anthonytrAuthor Commented:
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.
0
mbizupCommented:
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.
0
PatHartmanCommented:
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.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.