View Full Version : Subform Table Keys


wizcow2
09-17-2003, 08:06 PM
Hello

I have an Invoice form with a sub form.

The Invoice record source is the Invoice Table.
With InvoiceId as the key (auto number)(no duplicates)

The sub form record source is the InvoiceSub Table.
With InvoiceSubId as the key (auto number)(no duplicates)
I have a relationship with InvoiceId (number)

Should InvoiceId be a key as well?
And am I building this properly?

Thanks Tom

WayneRyan
09-17-2003, 10:30 PM
Tom,

Yes, InvoiceID should be a key also. You will use it to join the
two tables for forms, reports, etc.

If you use the Master-Child links for your subform, these fields
will keep the two forms in "synch".

You can also use the Tools --> Relationships to let Access
"know" that the two fields are related.

Wayne

Sorrells
09-17-2003, 10:30 PM
Tom,

I could be wrong but my feeling is that you have the two tables related by InvoiceId in a one to many relationship.

You must be referring to InvoiceId in your InvoiceSub Table. I would think that there are many of the same InvoiceIds in this table. It in never a good idea to make a field with repeating values a primary key.

The sub and main form have a parent-child relationship of InvoiceId. Thus a specific InvoiceId could bring up several records in the subform.

I'd recommend that you index InvoiceId in the InvoiceSub Table and leave it at that. The keys you have should suffice.

Sorrells
09-18-2003, 05:03 PM
WayneRyan,

Are saying about the same thing? If he has an autonumber as primary key and if he has more than one InvoiceID with the same values, what advantage is it to make it a primary key as well?

Perhaps I am mis-understanding what he means by the word 'key'.