Solved

How to stop tabbing to fields with data in?

Posted on 2011-02-21
6
286 Views
Last Modified: 2012-06-22
Hi all,

I have a continuous sub form with 10-12 fields on.  I have added checkboxes to the top of the form to say that if the checkbox is ticked the field becomes enabled.  This works fine when there is no data in any of the fields.  You tick the check box, the field becomes enabled and you can tab down filling in the data for all users.  

However if you later go in to add figures to a different field and tick the check box to enable that field it will tab to the previously completed field because there is data in it.  

Sorry if this is hard to understand.  Is there anything that I can add to this code so it only goes to the enabled field and not any other field that may have data in?

Private Sub Check_Absence_AfterUpdate()

 If Me!Check_Absence = True Then
    Me!Absence_Score.Enabled = True
    Me!Absence_Score.SetFocus
  Else
    Me!Absence_Score.Enabled = False
  End If

End Sub

Open in new window


Regards

Chris
0
Comment
Question by:smods
  • 3
  • 3
6 Comments
 
LVL 10

Expert Comment

by:VTKegan
ID: 34942656
I would use an option group at the top of the form, this way only one field could be enabled at a time.

You would then set an afterupdate event of the option group to set only one field to enabled to prevent tabbing to a control that is not enabled.
0
 

Author Comment

by:smods
ID: 34942721
Thanks VT.

All fields are currently not enabled when opening them form.  It's only when the check boxes are ticked that they become enabled.  However, even when the checkbox isn't ticked anything with previous data in can be edited.  Is that right?  Should it do that?

Regards

Chris
0
 
LVL 10

Expert Comment

by:VTKegan
ID: 34945558
Can you upload an example file.  

based on your code if you have a check box like this for each field, then it looks like you could enable more than one field.

So if you are not setting every other field enabled = false then you have more than one field enabled.  If you use an option group you could dramatically reduce the amount of code needed.
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:smods
ID: 34950887
Here you go VT.


ee-example.mdb
0
 
LVL 10

Accepted Solution

by:
VTKegan earned 500 total points
ID: 34951223
smods,

Here is the revision.  What I did: I edited your existing code to set the Tab Stop Property of the form to True and False based on the check box and that fixed the tabbing to the other controls.

I also created a new example that uses an option group.  Open up the main form that I created, and look at the code there.  I replaced about 100 lines of your code in about 15.  Just food for thought.  Both forms are working as you would want them, just another alternative.
ee-example--1-.mdb
0
 

Author Closing Comment

by:smods
ID: 34951943
Good job!! I really liked your idea so have implemented that instead!

Thanks

Chris
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now