Solved

Change one-to-one relationship to one-to-many relationship

Posted on 2010-09-10
6
913 Views
Last Modified: 2012-06-27
Hi ,

I made a relationship between two tables in my database in the Relationships window. The relationship should be one-to-many, but Access keeps assigning it as one-to-one. The structure of the tables is as follows:

mother table
- primary key = surveyid

child table
- primary key and foreign key = surveyid
- primary key = row number

Right now when I enter data into the child table, I am only allowed to enter one row and it gives me a primary key violation when I try to enter a second row. How can I resolve this? Should I try to change the relationship type, and if so how do I do that?

Thanks.
0
Comment
Question by:ghaphis
6 Comments
 
LVL 1

Expert Comment

by:JamesCronshaw1
ID: 33644719
Change your child table to drop the SurveyID from the Primary key, as it appears this is not required (though I could be wrong here dependant on your logic).  

In your Relationships window, select the relationship thats causing you the issue and double-click it to open the change dialog.  You can then make changes you wish to it (remembering to save of course!)
0
 
LVL 9

Expert Comment

by:borki
ID: 33644935
I am not sure what is wrong here. All your design sounds fine. to proof the concept I have knocked up a simple .mdb that illustrates this.

I suspect that something went astray when you created the key for the second table or the relationship.

MotherChild.zip
0
 
LVL 6

Expert Comment

by:JVWC
ID: 33645788
Create this:
mother table
- primary key = surveyid

child table
- primary key = autonumber
- foreign key = surveyid

Cheers
JC
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 6

Expert Comment

by:JVWC
ID: 33645878
Further...

mother table
- primary key = surveyid <<<OK

child table
- primary key and foreign key = surveyid <<< This will create a 1 to 1 relationship
- primary key = row number <<< Cannot have TWO primary keys in same table.

Cheers
JC
0
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Access MVP) earned 500 total points
ID: 33648537
ghaphis

If your foreign key (surveyid) has the Indexed property set to Yes AND No Duplicates, then this situation will arise. And as note, you cannot have two Primary Keys.   And further, do not even Index the foreign key, because IF ... you have a correct relationship with Referential Integrity set to Yes, JET will automatically create a (hidden) Index on the foreign table.

mx
0
 
LVL 75
ID: 33648706
"automatically create a (hidden) Index on the foreign table."

>> s/b automatically create a (hidden) Index on the foreign KEY.

mx
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

809 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