We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

How to create a Microsoft Access One to Many Relationship

Medium Priority
1,714 Views
Last Modified: 2013-11-29
I know I'm being silly, but I am completely stumped!  I have an Access database where I want to store manufacturers and their products.  I have two tables, the first (tblManufacturer) has three fields: an autonumber field which is the record ID (and Primary Key), a field for Manufacturer name and a Lookup field for the products they produce.  The second table (tblProduct) has three fields: an autonumber field which is the record ID (and Primary Key), a Lookup field which looks up the Manufacturer from the first table, and a product field.

What I want to do is look at a manufacturer in the Manufacturers table and click the lookup to see what products they produce.  Currently, when I do this, I get a list of ALL products in the Products table, regardless of their manufacturer.  I have tried everything I can think of and just about every combination of relationships, but I only ever get all records.  At the moment, I have a one to many relationship set between the ID field in the Manufacturers table and the Manufacturer field in the Product table set to include only those records where both fields match.

An example is: Manufacturer ACME has a record ID of 6 - In the lookup in the Products table, the record equals 6.  When I select the lookup in the Manufacturers table, I don't just see products relating to ACME, but I see all products, regardless of their manufacturer.

Please help!!
Comment
Watch Question

You can't have the Product in the Manufacturer's table as this will mean that 1 manufacturer can only product 1 product. If more than 1 Manufacturer can produce a product then you need to do a Many to Many relationship. This is done with 3 tables

tblManufacturer: ManufacturerID as PK
tblProducts: ProductID as PK
tblManufacturerProducts: ManufacturerID and ProductID as joint PK

Cheers, Andrew
MIS Liason
CERTIFIED EXPERT
Most Valuable Expert 2012
Commented:
As TextReport stated.

In the most basic sense your tables would look something like this:

tblManufacturers
ManufacturerID (Primary Key)
ManufacturerName
ManufacturerCountry
...ect

tblProducts
ProductID (Primary Key)
ManufacturerID (Foreign Key)
ProductName
ProductPrice
...ect

The should be related on ManufacturedID in the relationship window.

If this is done, it will create little (+) symbol in the Manufatures table.
Clicking the "+", will display all the products that that manufacture makes.

You can then use the form wizard to create a main form/ subform
Selecting a Manufacturer in the main form displays all the corresponding Products.

Here is a sample.
Examine it carefully.

I am sure you can modify it to work in your Database.
;-)

(But also as TextReport states, this gets a bit more complicated if one product can be made by more than 1 Manufacturer.)

JeffCoachman

db179.mdb

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
Perfect!!  Got me out of a dreadful hole!  Thank you.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.