Tab Control Problem

T

trekgoes2malaysia

I'm just wondering how I can add controls to tab control pages that
are bound to fields from different tables. I have 3 tables (road,
track and gym) with similar named fields and I want to create a tab
page for each table. Unfortunately, my tab control form only allows me
to view and set controls for one table. So even though I might have a
control bound to a field from table 'road', the information i enter
goes to the table 'track' because that is the default table for the
tab control form. My manual says I should be able to send and view
info from different tables using tab control but I can't seem to get
it to do so. Is the only solution to create a query that combines all
fields from each table??? Seems to defeat the purpose of a tab control
form then. Please help.

Patrick
 
R

Rob Parker

A form can only be bound to a single table/query. So, unless you use a
subform on the different pages of your tab control, you are limited to using
a query as the recordsource for your form if you want to get all the fields
from multiple tables. A possible problem here is that a query which
combines several tables may not be an updatable query (see
http://allenbrowne.com/ser-61.html for reasons why a query may not be
updatable). If your query combining multiple fields (perhaps with the same
field names) from different tables is updatable, then you will be able to
place bound controls on different tab pages which are bound to different
tables in the form's recordsource query; fields with the same name in their
underlying table will be differentiated by requiring an alias in the query,
to establish that differentiation.

The common solution to this situation is to use subforms on each of the
separate tab pages, and use a parent/child link to link each of these to the
same parent field in the first tab page, which will be based on a table
which contains the "master" primary field. If your tables contain a common
primary key field, this is easy to do - simply set the master/child fields
for each subform. If there is no common primary field, you will need to
leave the subforms unbound, and set their recordsource via VBA code for each
table according to their relationship to the recordset for the main form.

HTH,

Rob
 
T

trekgoes2malaysia

A form can only be bound to a single table/query. So, unless you use a
subform on the different pages of your tab control, you are limited to using
a query as the recordsource for your form if you want to get all the fields
from multiple tables. A possible problem here is that a query which
combines several tables may not be an updatable query (seehttp://allenbrowne.com/ser-61.htmlfor reasons why a query may not be
updatable). If your query combining multiple fields (perhaps with the same
field names) from different tables is updatable, then you will be able to
place bound controls on different tab pages which are bound to different
tables in the form's recordsource query; fields with the same name in their
underlying table will be differentiated by requiring an alias in the query,
to establish that differentiation.

The common solution to this situation is to use subforms on each of the
separate tab pages, and use a parent/child link to link each of these to the
same parent field in the first tab page, which will be based on a table
which contains the "master" primary field. If your tables contain a common
primary key field, this is easy to do - simply set the master/child fields
for each subform. If there is no common primary field, you will need to
leave the subforms unbound, and set their recordsource via VBA code for each
table according to their relationship to the recordset for the main form.

HTH,

Rob







- Show quoted text -

Thanks ROb. Will use the subform route.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top