473,395 Members | 1,386 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How do I Navigate to Next Tab Automatically

Hi,

I am trying to create a data entry form for a large database. There is a parent form with 6 forms linked with a one-to-one relationship (due to a large number of fields) and several tables linked with a one-to-many. All have auto update/delete checked. The date entry form uses tab control (across 11 tabs) and subforms for some of the tables. I have two problems...

Firstly, ** Edit Form Doesn't Display Existing Data **

Secondly, when using the tab key to move through the fields in the table, when I get to the end of a tab control, instead of moving to the next tab control for the same record, it moves to a new record on the same tab.

I am fairly new to access and not familiar with all the code etc behind it, so I would be grateful for any advice!

Thanks
Dec 15 '11 #1

✓ answered by sierra7

Rachel,
Obviously I agree that you have a highly complex situation and endorse the previous advice to simplify if possible.....

But to address the mechanics of where you are stuck, Move between Tabs, there are some variations which may seem complicated due to your complex situation. But there is logic so stay with me..

First you understand that you have Parent form. It seems that some of the fields from the Parent recordset may be grouped on individual tabs because of shortage of space.

This is the most simple case, where the next field you want to move to belongs to the same recordset i.e. not in a new sub-form. You just put some code in the Lost Focus event of the last field on your current tab to set focus to the next field you want to visit. Even if it is on a different tab-page, Access will find it and put the focus there (so long as the field is Enabled).

If you are moving from a field in the Parent recordset to a field in a Sub_Form on another tab, there are three options;
  1. Move to the sub-form control
  2. Move to a control within the sub-form
  3. Move to the Tab Page

The first option is the simplest, just setfocus to the sub-form. The preset Tab-Order within the sub-form will then take over.

If you want to move to a specific field within the subform then you need the second line in the example below. This assumes that PhonesCustomers is a sub-form in a tab-page listing the one-to-many contacts within a customer's organisation. First set focus to the sub-form then move the focus inside it to the control you want.
Expand|Select|Wrap|Line Numbers
  1. Private Sub ExchangeRate_LostFocus()
  2. Me!PhonesCustomers.SetFocus
  3. Me!PhonesCustomers.Form!PhoneNumber.SetFocus
  4. End Sub
  5.  
The third option does much the same as the first. The tab-control has a name of its own (I have one called TabCtl72) and each tab has a Page number starting from 0 (zero). You might need to use this option in a Read-Only situation, where none of the controls in the sub-form will accept focus.
Expand|Select|Wrap|Line Numbers
  1. Private Sub ExchangeRate_LostFocus()
  2. Me.TabCtl72.Pages(2).SetFocus
  3. End Sub
  4.  
The next problem is when you are in one sub-form and want to move the focus to another field in another sub-form. Here you have to issue three seperate commands, first to move up to the Parent form from within the first sub-form. Then to move focus to the next sub-form; and finally to a specific field.
Expand|Select|Wrap|Line Numbers
  1. Private Sub PhoneNumber_LostFocus()
  2. Me.Parent.SetFocus
  3. Me.Parent!NextSubform.SetFocus
  4. Me.Parent!NextSubform.Form!NextField.SetFocus
  5. End Sub
  6.  
Note that all three commands are directed via the Parent form.

S7

12 13973
NeoPa
32,556 Expert Mod 16PB
I would suggest you take this a number of steps back first. What you are planning is not a usual approach and is quite flawed in concept. Due to the unusual nature of your approach, and the relative lack of detail in your question, it's hard for someone to guess at what you want with enough detailed accuracy to allow appropriate alternatives to be suggested. What you describe is the normal behaviour of subforms.

An alternative to consider would be a single form with tabs, but having bound fields on each tab, rather than separate sub-forms.

That said, I expect the best advice I could give would be to revisit your overall design, starting with the data structure (I can think of no situation where one-to-one relationships would be desirable. There may be possibilities here, but very few I expect).

Following closely behind that would be to try out your concepts with a structure which is considerably simpler until you are sure they can handle what you need. Only then build the extra complication into your design. Otherwise you should sensibly expect all sorts of related (to the complexity rather than the concept) problems.
Dec 15 '11 #2
Hi, thanks for your reply. I'm sure the design is not ideal as I am a beginner in Access! The database is for data from a very long household survey, and there are >255 fields in the main table so I had to split it into at least two tables with one-to-one (perhaps it would have been better to stick to 2?). I am not sure how I can get around the problem of one-to-one tables with so many unique fields?

I have a single form with tabs, and many of the fields are in bound fields on the tabs. However I could not add all of them in this way (I assume this was again becuase of the large number of fields). All the one-to-many are in subforms. I should have said that the tab key issue is not with the subforms but with the bound fields which are the last fields on each tab (I appreciate that that is the normal behaviour in subforms).

Grateful for any advice!
Dec 15 '11 #3
NeoPa
32,556 Expert Mod 16PB
First of all, my original advice still applies. You will still find the whole process more reliable if you remove many of the complexities involved with such a complicated setup. However, I'll leave that with you for now and consider the distinctly non-newbie problem's you're faced with.

I would first consider using a BeforeUpdate event procedure for the form which cancels any update except those that are triggered in the way you choose. The obvious solution here would be to provide a Command Button control that the user must click on to save any record.

Next you'd need to determine what happens, IE. which events are triggered, when you trigger a save (that is cancelled) by moving past the last control on the tab. When you can reliably handle this situation you can place code in the relevent event procedure which passes control to the next page instead.

Does this sound like it makes sense?
Dec 15 '11 #4
Thanks - this makes sense in theory but I have no idea how to do it... will go away and do some reading! I did have a similar but simpler database which had just one main form and several subforms, and the tab controls all worked fine. I also had a previous version of this database with one form plus subforms, which I had created in the same way but had the problem with the tab key - I have been through all the properties and built it up from scratch again but I cant figure out what's different. Thanks for your help...
Dec 15 '11 #5
Mihail
759 512MB
In my opinion is almost impossible to have an object with more than 255 properties.
I think that this is also the reason of Access designers to limit the number of fields (at a very large range: 255).
So, every time I hear about, I suspect a (very) poor design of database.

Take a look here:
http://bytes.com/topic/access/insigh...ble-structures
and see if you don't change your mind about store more than 255 fields (properties for a SINGLE object, in fact) in a single table.
Dec 16 '11 #6
sierra7
446 Expert 256MB
Rachel,
Obviously I agree that you have a highly complex situation and endorse the previous advice to simplify if possible.....

But to address the mechanics of where you are stuck, Move between Tabs, there are some variations which may seem complicated due to your complex situation. But there is logic so stay with me..

First you understand that you have Parent form. It seems that some of the fields from the Parent recordset may be grouped on individual tabs because of shortage of space.

This is the most simple case, where the next field you want to move to belongs to the same recordset i.e. not in a new sub-form. You just put some code in the Lost Focus event of the last field on your current tab to set focus to the next field you want to visit. Even if it is on a different tab-page, Access will find it and put the focus there (so long as the field is Enabled).

If you are moving from a field in the Parent recordset to a field in a Sub_Form on another tab, there are three options;
  1. Move to the sub-form control
  2. Move to a control within the sub-form
  3. Move to the Tab Page

The first option is the simplest, just setfocus to the sub-form. The preset Tab-Order within the sub-form will then take over.

If you want to move to a specific field within the subform then you need the second line in the example below. This assumes that PhonesCustomers is a sub-form in a tab-page listing the one-to-many contacts within a customer's organisation. First set focus to the sub-form then move the focus inside it to the control you want.
Expand|Select|Wrap|Line Numbers
  1. Private Sub ExchangeRate_LostFocus()
  2. Me!PhonesCustomers.SetFocus
  3. Me!PhonesCustomers.Form!PhoneNumber.SetFocus
  4. End Sub
  5.  
The third option does much the same as the first. The tab-control has a name of its own (I have one called TabCtl72) and each tab has a Page number starting from 0 (zero). You might need to use this option in a Read-Only situation, where none of the controls in the sub-form will accept focus.
Expand|Select|Wrap|Line Numbers
  1. Private Sub ExchangeRate_LostFocus()
  2. Me.TabCtl72.Pages(2).SetFocus
  3. End Sub
  4.  
The next problem is when you are in one sub-form and want to move the focus to another field in another sub-form. Here you have to issue three seperate commands, first to move up to the Parent form from within the first sub-form. Then to move focus to the next sub-form; and finally to a specific field.
Expand|Select|Wrap|Line Numbers
  1. Private Sub PhoneNumber_LostFocus()
  2. Me.Parent.SetFocus
  3. Me.Parent!NextSubform.SetFocus
  4. Me.Parent!NextSubform.Form!NextField.SetFocus
  5. End Sub
  6.  
Note that all three commands are directed via the Parent form.

S7
Dec 16 '11 #7
TheSmileyCoder
2,322 Expert Mod 2GB
Could you please try to describe what the general purpose of your application is, what it is you need to achieve with it? What kind of information are you gathering, and for what purpose.
Dec 16 '11 #8
Mihail
759 512MB
Hi S7 !
Forget me, but I can't understand how is fired the _LostFocus event for the sub_form.
Dec 16 '11 #9
NeoPa
32,556 Expert Mod 16PB
Mihail:
I can't understand how is fired the _LostFocus event for the sub_form.
That was never mentioned in S7's post. Only the last control on the form, that is within the sub-form, needs it's LostFocus event handled.
Dec 16 '11 #10
Mihail
759 512MB
My bad. Thank you, NeoPa !
Dec 17 '11 #11
sierra7 - thanks so much for your help! problem resolved!
Dec 22 '11 #12
NeoPa
32,556 Expert Mod 16PB
At this stage it would make sense to select the post that most helped you as Best Answer for the thread. As your thanks were reserved for S7 I assume it will be one of theirs, but only you can do that.
Dec 22 '11 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: sophocles the wise | last post by:
automatically post data & click buttons on sequence of web pages with AxWebBrowser Hi, I need to post stuff everyday to a website and am working on a VB program to do this for me. I am a...
6
by: Patrick Coghlan | last post by:
I want to create about 4 forms with the same dimensions and background colours, similar to the forms one has to traverse when installing various software packages. I'm using Visual Studio and...
7
by: husamal_ahmadi | last post by:
Hi everyBody: I have this question which really drive me cruzy, By using VB.Net: How can I let the internet explorer navigate in the same window either by using win32 API or by using...
2
by: zek2005 | last post by:
Hi!!! I've made a form with a 'select' statement through a echo('<select name="res">'); echo('<option selected value=""> Select option</option>");'); while($row = mysql_fetch_array($resumen))...
4
by: Peter Newman | last post by:
i have a dataset and want to step thrpugh each row each time a user clicks a button,
2
by: samueltilden | last post by:
I started a new job and the version of Visual Studio 2005 that I am now using does not have the Navigate Backward Button nor the Navigate Forward Button in the Standard Toolbar, and they are not...
1
by: Robert Dufour | last post by:
Vs2005, .Net 2.0, vb.Net, Winforms I have a form with a binding source, a binding navigator, a table adapter and a dataset (all using sql 2005 same table, to keep it simple) When the user tries...
2
by: Tina | last post by:
How can I programmatically navigate a website just as a user would? click on buttons, hyperlinks, etc. I know how to read nodes using XPath but I don't know what classes to use to navigate. I...
1
by: esurkes | last post by:
I have been able to create a web browser control in a form that properly opens a website based on an address from another form. Now I am trying to figure out how to set the corresponding...
8
by: Adam Tippelt | last post by:
Scenario: I've got a table for adding records, with a subtable for all data requirements related to that record. I've built a 'view' form to navigate through the records, so that you can view the...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.