Navigating a Master Table and Multiple Related Tables

mukiwa

New member
Joined
Nov 14, 2007
Messages
3
Programming Experience
Beginner
I am using the following book as a guide:
Expert One-on-One™ Visual Basic®2005
Database Programming
Roger Jennings

The example explained by Roger Jennings on pages 73-75 is close to what I need to do, but not quite. The section is titled “Add Multi-Level Subforms.”


The example uses the Northwinds database. The Customers Table, the master data source, is added using bound text boxes and a data navigator by dragging the details view of the Customers Table onto the form.
The nested table under Customers, Orders, is then added using DataGridView.
The nested table under Orders, Order Details, is then added using DataGridView.
Navigation is performed using the navigation bar of the Customers table. One cutomer’s information is shown in the bound text boxes, and the orders related to this customer are shown on the Orders data grid view. The Order Details data grid view shows the details of each order.

The displayed data from 3 tables represent 3 levels of a heirarcy.

My needs require me to do something similar. I only need 2 levels of the heirarchy, but I need multiple tables on the second level. Imagine the Northwinds company maintains much more information about their customers than just Orders. Imagine there is also a table for credit card accounts, communication history, family members, etc.

I need to have 5, 10, 20, 30, even 50 tables that are all related to the Customers Table in the same way. However, these tables cannot be merged into one because they contain different types of data.. I need to scroll through the Customers Table data and see data from all the related tables (the ones I am calling the second level, similar to the Orders Table) updated accordingly.

For example, scroll to one customer, you see all the customer information in the bound text boxes. In one DataGridView, you see a list of orders and associated information. In another DataGridView, you see a list of credit card accounts and associated information. In another DataGridView, you see a list of family members and associated information. In another table, you see a list of all previous correspondence with the customer, emails, calls, etc.

I have seen a posting for a similar need. The responses simply suggested subforms. However, the term “subform” is the same term Roger Jennings used for his example, but the approach he used only allows one nested table on each level of the heirarchy. The only way to add additional related tables is to drill down further. I do not want to drill down. I want 1 master table with many related tables 1 level down. Like 1 master, 50 children. I know that’s a lot of children, but it is the only structure that works for me.

One more note: what first seemed like the answer was using multiple SubDataSheets under my master table, but I learned that only one nested table or SubDataSheet is allowed at each level. Again, I need to view and navigate a master table along with multiple tables that are related to the master table in the same way.
Thanks!
 
Having one parent and many children isn't a problem. You just have different dataGridViews for each child.

As long as you load your parent table first, you then load your child data after this, i.e.

VB.NET:
.FillParent
.FillChild1
.FillChild2
.FillChild3

There really isn't anything stopping that from happening. As long as you have your relationships set up correctly in the first place, they should set up as dataRelations in VS.

Check out the link in my signature for the 2005 data walkthroughs, there are some relating to data access and displaying parent-child. These are the walkthroughs that myself and many others on these forums use(d) and most of us would recommend.
 
Back
Top