473,386 Members | 1,873 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Subforms with queries and relationships

Hi.
First of all: I started working with databases two weeks ago, so some
questiones may seem senseless...

I want to create a form for the data collection of different studies.
Each study has an ID which is the primary key and some additional
information like date of publication which are included in table 1.

Additional other tables are the outcome tables that have the study ID
as a foreign key.

I created a form which is based on the query that included table 1 and
some of the additional other tables.
My problem is that I could not include all the fields in one query
because I have to use more than 70 fields in total. I tried to resolve
this in including subforms to my form that are based
on another query which relates table 1 with the primary key to the rest
of the additional tables which use the study ID as a foreign key.
If I enter data to the main form it works but if I try to enter data
into the subform I get the error message "the changes you requested to
the table were not successfull because they would create duplicate
values in the index, primary key or relationship".

I am not sure if I explained clear enough what the database looks like
but if someone has any idea, I would be really glad!!
Thanks,
Tina

Apr 26 '06 #1
3 1284
Tina:

It sounds like you are trying to add a record to table 1 that has the
same primary key as an existing record. For subforms, do NOT include
the primary key's table in the underlying query. Instead, just have a
query that returns all of the related records (e.g. only include table
2). Then, in your subform object's properties, you're going to want to
make sure the 'Link Child Fields' (your foreign key from table 2) and
the 'Link Master Fields' (your primary key from table 1) both reflect
the linking field names. This creates the relationship between the
data on your subform and the main form, and new records added to the
related table will automatically have the primary key from your table 1
inserted in them, without trying to add a new record to table 1.

Note that you will need to have the primary key field on your main form
and the foreign key field on your subform, though they need not be
visible.

HTH,
Jana

Apr 26 '06 #2
Jana:

Thanks a lot!
It seems to work now. It took me some time to fix it because you cannot
ad a lot of tables to the "Link Child field" and I had to summarize all
my tables to some few but I think this is better anyway.
Have a good one!
Tina

Apr 26 '06 #3
Tina:
You're quite welcome!

Jana

Apr 27 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Alan Bloom | last post by:
I'm designing a db which stores client details but each client has multiple 'occasions'. For each occasion there is a section which has items purchased (there are sometimes none, sometimes...
3
by: Stephen | last post by:
It is possible to relate queries to tables, right? It seems logical but when I try to match my queries to any of the tables or even to each other it gives me a blank relationship. What could I...
12
by: Paul T. RONG | last post by:
Is it possible to divide a tall subform with 80 records to two subforms each with 40 records? Dear All, What I have: Tables: tblProduct, tblOrder, tblOrderDetail
0
by: misscrf | last post by:
I am currently working on a database, in 3rd normal form, which is for candidates who apply for a job with the law firm that I workd for. My issue is with good form design. I have a main...
1
by: ken | last post by:
Hi, Reports can be based off of queries or tables. Can they be based off of subforms? The reason I ask is because I have a bunch of subforms already that filter the data and if I didn't have to...
3
by: Phil | last post by:
I've posted this a few times without any luck, hoping for some fresh ideas on this. I'm pretty certain this can be done. I've been using a micrsoft template to create a supplier database called...
2
by: Gari | last post by:
Hello, I have three subforms (let’s call them SFA, SFB, SFC) on one form (the reason there are subforms is that they are related to different queries). Each of these subforms contains a data...
22
by: banderson | last post by:
Hello I'm new to developing databases in Access and using Access2003. I have a dataset with a few many to many relationships that I have created linking tables for to make multiple 1:M relationships....
3
by: Patrick A | last post by:
All, My form "FRM_Main" contains 2 subforms, each an instance of the form "FRM_Testators" The object name of instance 1 of the form is "SFRM_Clients". The object name of instance 2 of the form...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.