Solved

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

Posted on 2010-09-10
6
919 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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

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…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
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…

792 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