View Full Version : single main table affecting many others


thargor
12-10-2003, 12:45 AM
I have a table with employees in it. I also have many tables that have many fields that the employees need to fill in.

I have created a relationship from the employee table to the other tables with the primary key so that there are 1 to many relationship that all stem from the employees table.

What I want to do is (and it may be more useful if I put this topic on the forms thread) have a situation where an employee logs in and then is able to put his/her data in each related table without having to put their name in every table they put data in.

So in effect I want the login to then place their name in all the foreign fields for all the tables that are related back to the employees table.

How do I do this?

namliam
12-10-2003, 05:41 AM
YOU DONT !

Thats the whole idea of relational databases. You have data in 1 table with a PK and only store the PK as a FK in the second table. Then you DONT store the name or anthing else from that first table in the second table except for the PK/FK.

Regards

thargor
12-11-2003, 03:31 AM
Yeh Yeh I know that but...

Say for example I just go to a table that is related to the main table via a pk/fk. If I enter data directly into that table it will ask me to enter the name for the fk or it wont add the other data.

However if you add the name to the fk field then all is fine.

What I want to do is create a relationship - albiet via vb or a sql statement that says - once a name is selected from the main form (main table of names) then all related tables (subforms) will update their fk to reflect the selected name so the poor person who selected their name originally doesnt have to go and enter their name in the fk field to enter data in that table.

namliam
12-11-2003, 04:19 AM
1) DONT use names as PK's use autonumbers
2) Create a mainform/subform and link them to accomplish what you are trying to do....

Regards

thargor
12-11-2003, 05:39 AM
Already done that. Already tried that and it works.

However I need to link about 20 subforms to the main form at once. 1 to 1 is easy but to link them all at once when someone selects their name is what I dont know how to do.

It will also mean that due to the large amount of subforms, Ill need to have a button control or something like that so the person can select which form they would like to fill in next. That is why I want the selected name to automatically appear on the fk on the row that they will fill in in each form all at the same time.