Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

adding data to juction table

Status
Not open for further replies.

waymond

Programmer
Mar 1, 2005
118
US
I have a juction table and I cannot get the data from the tables related it to it in the junction table??


Please help
 
I tried it with a query and with a form. I have a main table with busID, ProgID, FuctionID,
business process table has
BusID and Processes
this table is linked to SubProcess table
which has BusID, Process, Subprocesses not all sub processes have busprocess. It is linked by one busID to many subprocesses for BusID.

Next I have a program table that has ProgID and program name the programs run the business Process.

Next I have a table called functions which include FuncID, FuncName

then I have the main table with BusID, ProgID, FuncID Process, Subprocess, Program the main is the junction table
which has the combination primary keys BusID, ProgID, FuncID
there could be several programs that support the subprocess, also there could be several functions that support the Program or and all cases there could be no programs or functions.

Please Help
and thanks
 
I am a bit confused with your design.

To recap...
Code:
Main table
busID, ProgID, FuctionID

SubProcess
BusID, Process, Subprocesses 

functions table
FuncID, FuncName

main table
BusID, ProgID, FuncID  Process, Subprocess, Program 

Junction table
BusID, ProgID, FuncID
When I look at your Junction table, it has the same fields as the "Main table".

Let's start over...
When giving the name of your table, also identify the primary key, and where appropriate, the foreign key.

tblName
PKFieldName - primary key

tblJunctionName
PKFieldName - foreign key to tblName

etc.

...Moving on
Assuming you have defined your relationships correctly, and you have have used the Relationship tool (from the menu, "Tools" -> "Relationships", add your tables, click and drag the primary key from one table to the foreign key in the related table, and enforce referential integrity)

There are two approaches to easily creating the junction records. Assumptions tblMain1 with PK1 as the primary key, tblMain2 with PK2 as the primary key, and the tblJunction with PK1 and PK2 as the foreign keys that reference tbleMain1 and tblMain2.

1) Create a form based on a main table, tblMain1. Create a subform based on tblJunction. Hide the text box PK1 and turn the text box for PK2 to a combo box that references tblMain2. Embed the subform into the main form. By creating your relationships before creating the form, Access will automatically link your form / subform.
...or
2) Create a form based on tblJunction. Convert PK1 to a combo box that points to tblMain1 and PK2 to a combo box that points to tblMain2.

I find the first approach more functional since I can see the related records in one form. The second approach may be easier for data entry.

Make sure to have the "Properties" window open when working with the form design (from the menu, "View" -> "Properties")

Richard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top