Solved

How do you assign forign keys in Access 2007

Posted on 2009-05-11
2
189 Views
Last Modified: 2012-05-06
having trouble assigning forign keys
0
Comment
Question by:1030071002
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 12

Accepted Solution

by:
geowrian earned 25 total points
ID: 24361066
In a nutshell, you have a primary key from table x and the foreign key in table y. Make sure the types are compatible (i.e. an autonumber in table x with a long integer in table y). That's basically it. Depending on the indexing options you select on the foreign key, the type of relationship will change (i.e. indexing: yes with duplicates allowed will create a many-to-one relationship).

To enforce referential integrity (as is often what people are looking for with access databases from my experience):
1) Right-click off a table and choose "Relationships".
2) Add tables x and y to the view, if they are not already there.
3) Drag the primary key in table x to the foreign key in table y
4) Check enforce referential integrity and the cascading options you need.
0
 
LVL 85

Assisted Solution

by:Scott McDaniel (Microsoft Access MVP - EE MVE )
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 25 total points
ID: 24363591
Access can handle most of the heavy lifting, if you setup your tables as geowrian describes. For example, most of the time in Access a foreign key relationship is handled through either (a) a combo or listbox or (b) a subform. If you use a combo/listbox, then you simply set the ControlSource of that control to the field in your table that would house the foreign key value, and you'd set the RowSource of the control to show the records from the foreign table.

If you use a Subform, you'd set the Master/Child links to reflect the relationship between those two tables, with your Master being the "one" side of the 1-to-Many relationship, and the Child (i.e. subform) being the "Many" side of that relationship.
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question