Solved

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

Posted on 2010-09-10
6
908 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

744 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now