Access 2000 relationships and data entry/key fields

G

Guest

I have TBL_Project with a primary key as an autonumber named Project_ID.

I have a second table named TBL_Project_Name with its primary key
(Project_Name_ID, also autonumber) and foreign key Project _ID as a number to
link them together. I also have a text field in TBL_Project_Name called
Project_Name, as a text.

I have a one-to-many relationship between TBL_Project and TBL_Project_Name,
as there may be more than one name assigned (and users looking up) to a
Project.

When entering a new Project_Name in a form and subform, (or for that matter,
in a query), I cannot get the Project_ID field to autonumber populate when I
enter a new Project name in TBL_Project_Name.

Any suggestions?
 
J

JP

It sounds as if you've got things upside down.

If Project_ID is the foreign key in TBL_Project_Name, then you must first
enter data into TBL_Project so that the Project_ID autonumber will be
incremented, and then let the new value of Project_ID travel to
TBL_Project_Name via a link in a form. In other words, you cannot enter
data into TBL_Project_Name and expect to have the Project_ID field in
TBL_Project auto incremented.

The way one would normally build something like what I think you want to
build is as follows:

1. You have a form bound to TBL_Project. The form contains a subform bound
to TBL_Project_Name. The field linking the form to the subform would be the
Project_ID field.

2. You enter a new project in the main form to create a new row in
TBL_Project.

3. Once you have entered the new project in the main form, you can go to
the subform and start adding project names. Each row in TBL_Project_Name
would receive the Project_ID from the main form (i.e., the foreign key) and
would automatically have its autonumber field incremented to fill in the
Project_Name_ID.
 
V

Van T. Dinh

On a Form (linked to TBL_Project) / Subform (linked to TBL_Project_Name),
have you set the LinkMasterFields / LinkChildFields of the SubformControl?
 

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