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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

relation for subfrm and sub sub frm

Status
Not open for further replies.

amna77

Programmer
May 27, 2003
69
0
0
GB
hi I have 4 tables
1:tblMain =Primerykey:IngID is Autonumber
2:TblTrend =Primery Key=IngtrendID is number
3:tblsymbol =PromeryKey=IngsymbolID is number
4:tblDefects
in the relationship window, I have joied, tblTrend and tnlsymbols to tblmain, by ID's. Thats fine.
now I want to join tbldefects to tbltrend and tblSymbol. how would i do that?
actaully what i want to do is, I have main form based on tblmain.
and there are 2 sub forms, frmtrend, and frmsymbol (by using tab control). now in those subforms, I have sub subform frmdefects. that one frmdefects, i have in subfrmtrend, and also in subsymbol.
can you please tell me how would i do a relation?
Please.
Thanks
 
Relationships simply join the primary key fields from one table with the corresponding foreign key fields in another. These are generally the same fields used in forms and subforms in the Link Master/Child properties.

Duane
MS Access MVP
[green]Ask a great question, get a great answer.[/green]
[red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
[blue]Ask me about my grandson, get a grand answer.[/blue]
 
amna77

Have you tried using the Relationship tool within Access?

From the main menu, select "Tools" -> "Relationships".
Add your tables.
Then graphically "link" the tables by first clicking on the primary key in one table and dragging it to the corresponding "foreign" key in the other table. A popup window will present you with the option to "Enforce referential integrity" -- most of the time, say yes, and cascading updates and deletes.

Having said that, I am not sure about your design.

tblMain
IngID - primary key, Autonumber

TblTrend
IngtrendID - primary key, numeric

tblsymbol
IngsymbolID - primary key, numeric

tblDefects

YouSaid said:
I have joied, tblTrend and tnlsymbols to tblmain, by ID's

How? Are you saying
tblMain.IngID -> TblTrend.IngtrendID -> tblsymbol.IngsymbolID

If so, I do not think this is what you to do. In general, the way you approach this type of thing is to a) define the type of relationship, and then use the appropriate design to incorporate the relationship.

For example, if you have a one-to-many relationship between Main and Trend -- one Main record can have many Trend records, but a Trend record will have only one Main record -- the typeical approach is to create a "foreign key" on the Trend table that matches the primary key on the Main tabel. tblTrend would become...

TblTrend
IngtrendID - primary key, numeric
IngID - foreign key to tblMain.IngID, long interger

You may have a better idead of this process if you review some background documentation...

Quick overview
Fundamentals of Relational Database Design by Paul Litwin (doc)
Fundamentals of Relational Database Design by Paul Litwin (HTML)
283878 - Description of the database normalization basics
304467 - ACC2000 Defining Relationships Between Tables in a Microsoft Access Database

Speaking from the "school of hard knocks", better to spend some time and start off with a good design rather than start quickly and fight a poor design.

Richard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top