Tables & Sub Forms

R

Robin

Hello

I am quite a novice at databases and want to know to
create a sort of sub table or form.

The Main table contains all the contact details but I
want to be able to have a separate table (made into form)
that contains sub contacts but whilst having it still
linked to the main initial contact. I want this
information to be show on a separate form but it always
seems to create new records and does not link it to the
initial main contact... Any help is appreciated.
Robin
 
R

Rick

You are looking for a one-to-many relationship. You can
read the access help files and/or look at the sample
Northwind database for examples. Basically, you have two
tables, one is your main contact table, and one is your
sub-contacts table. They are linked by a unique field
like a Contact ID or you could use an Autonumber field.
You create two forms, one is based on the Main contact
table, the other is based on your sub-contact table.
Then, you have a couple of options for bringing them
together. Most commonly, you could use a form with a
subform layout. The easiest way to do this is open the
main form in design view, hit F11 to bring up the database
window, the drag and drop your subform onto your form.
Access recognizes this as a form/subform setup and usually
links the two underlying tables automatically on the
unique field explained above. So, for every contact you
enter into the database, you have a subform
of "subcontacts" that are linked to the contact. Access
even automatically populates the unique field in your
subcontacts table so you don't need to display this field
in your subform. The Order/Order Details forms of the
Northwind database are good models to follow. HTH
-Rick
 
G

Guest

Hi thanks for this information, I have got all this to
work now and I have put done it so that the subform opens
in a new window and to get there you click on open form
button. When you open the form though it appears blank
even if you are in a main contact that already has a
subcontact is there away for it to pick know that there
is a sub contact and display this information?

Thank you verymuchly.
Robin
 
R

Rick

Sure. On your main form in design view, make sure the
wizard button is activated in the tools section and then
add a command button to your form. Select Form
Operations, and Open Form. Selct the form you want to
open (your subform), and then, on the next screen, select
the first radio button, the one that allows you to
syncronze two forms based on a particular record. Select
the field that joins the two tables, and complete the rest
of the wizard. That should do it!
-Rick
 

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