General discussion

Locked

MS Access 2002 - Building a Primary Key

By mtennant ·
I'm new at using MS Access. I've gone to the Fred Pryor Workshops - Beginning and Advanced, and I bought the MS Access 2002 Bible. According to the Bible, it can be done, but I'm having trouble understanding the details of how to create the Primary Key that I want.
I'm working with a db that has a table of Family names using FamilyID as Primary Key and need to link it to another table that contains a list of all the children in that family. I'd like the primary key in the children's table to be FamilyID, a hyphen, and a 2-digit sequential number.

This conversation is currently closed to new comments.

6 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

by john.a.wills In reply to MS Access 2002 - Building ...

Forget the hyphen, or put it in when you print the key, which will be rarely. When creating the children table start with columns FamilyID and SerialNo. Mark both of these columns with the little key, and together they will form a single key.

Collapse -

by mtennant In reply to

Didn't help because I may not have given enough information. See my comment from 5/16/06 for more info.

Collapse -

by mtennant In reply to MS Access 2002 - Building ...

Thanks for answering so quickly. I forgot to mention that there is already data in this db. What I'm striving for is that the SerialNo would be automatic as we entered each new child. I entered the FamilyID for each child in the family and added the SerialNo field but didn't populate it yet (should it be defined as AutoNumber or just Number?). It appears that I must enter a SerialNo for each child before it will create the index. Is there anything else I need to know to make the number automated?

Collapse -

by john.a.wills In reply to MS Access 2002 - Building ...

You will have to construct the serial number each time you insert a new child. You can do this in VBA or let the user choose the serial number and hope he gets it right. As there is a good chance of mistakes, and hence the loss of child data, I suggest a button to start some VBA to search the child table for the FamilyID and count up by one.

Collapse -

by mtennant In reply to

This is helpful. I've been working around it for now and able to get all the reports i need so far. I don't know how to program in VBA, but I see there's a few chapters dedicated to it in my Bible so I'll give it a try. Doesn't sound too complicated. Thanks for your help.

Collapse -

by mtennant In reply to MS Access 2002 - Building ...

This question was closed by the author

Back to Software Forum
6 total posts (Page 1 of 1)  

Related Discussions

Related Forums