Beginner- duplicate values and indexs

B

beginneratbest

I have created a database, it has 12+ tables and to make it easier for the
users it is set up as a form with subforms. I get an error message when i
try to input a second entry in a subform. The error says that i can not
enter duplicate values, but I have changed all the indexes to "yes" allow
duplicates and left the primary key as "yes" no duplicates. I still got the
error. I then changed all the indexes to "no" and still get the error. I am
very new to access but have run out of ideas. any suggestions would be
appreciated
 
R

Ray C

What I would do to solve this kind of problem is to go directly to the table
that the subform is based on and manually enter data into that table and see
which field is causing the duplicate value. Pay attention to default values
that Access automatically may enter for you as defaults.

Ray
 
K

Ken Sheridan

My guess would be that the form and subform are linked on the primary keys of
each one's underlying table. Generally a subform will be based on a table
which is related many-to-one to the parent form's underlying table. The
LinkMasterFields property of the subform control would thus be the primary
key of the parent form's table and the LinkChildFields property the
corresponding foreign key in the subform's table. A parent form might be
based on Customers and a subform on Orders for instance, with the CustomerID
fields linking them.

Ken Sheridan
Stafford, England
 
B

beginneratbest

I sort of understnad what you said, but how do i go about fixing it? Im not
sure what a linkchild field is, please explain
 
K

Ken Sheridan

Your main form will have within it one or more subform controls. A subform
control is the control which houses the subform. If you open the main form
in design view and select a subform control and open its properties sheet, on
the Data tab you'll see LinkMasterFields and LinkChildFields properties.
These are what links the subform and parent form so that the latter shows the
records which are related to the current record in the main parent form. The
LinkMasterFields property is normally the name of the primary key in the
parent form's underlying table, and the LinkChildFields property the name of
the corresponding foreign key in the subform's underlying table.

For an example take a look at the Orders form in the sample Northwind
database which comes with Access. You'll see that this contains a subform
control Orders Subform whose source object is the Orders Subform form (a
subform control and its source object don't necessarily have the same name,
but can do). If you open the subform control's properties sheet you'll see
that its LinkMasterFields and LinkChildFields properties are both OrderID,
the first being the primary key of the Orders table and the second the
foreign key in the Order Details table which references the primary key of
Orders. Consequently the subform shows only the order details for the
current order in the parent form.

Ken Sheridan
Stafford, England
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top