Solved

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

Posted on 2010-09-10
6
923 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
[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
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 - Microsoft MVP, Access and Data Platform) 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

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…
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

726 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