473,386 Members | 1,699 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.

Relationship Link

I have 3 tables:

tbl_customer
-CustID
-fkeyMarketingID
-CompName
-CompAddr
-ContactName
-ContactAddr
-Ph
-Fax

tbl_Marketing
-MarketingID
-fkeyMarketItemID
-MarketQty
-MarketDateSent

tbl_MarketDetails
-MarketItemName

The relationship looks like this:
tbl_MarketDetails (one) ------ (many) tbl_Marketing , (enforce
referential integrity - ticked ) , (join type - rows in both tables equal)

tbl_Marketing (one) ------ (many) tbl_customer , (enforce referential
integrity - ticked ) , (join type - rows in both tables equal)

Problem: I created a query with all the 3 table fields in this query where a
form (frm_newcustomer) is linked. It does not work in terms of allowing me
to save new entries in the form. I get the following message:
"You cannot add or change a record because a related record is required in
table 'tbl_Marketing' "
I don't understand - every field from the 3 tables is accounted for in the
query.
Nov 13 '05 #1
6 1863
This error can be triggered by the presence of a Default Value in the fields
of the lookup tables, or a Default Value in the controls that are bound to
the lookup tables.

Although you are not trying to add records to those tables, Access (wrongly)
applies the Default Value, and then complains that it can't add the record.
Removing the Default Value solves the issue.

There are other possible causes, but that one is less than obvious to track
down.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Gary T." <g4****@hotmail.com> wrote in message
news:43***********************@news.optusnet.com.a u...
I have 3 tables:

tbl_customer
-CustID
-fkeyMarketingID
-CompName
-CompAddr
-ContactName
-ContactAddr
-Ph
-Fax

tbl_Marketing
-MarketingID
-fkeyMarketItemID
-MarketQty
-MarketDateSent

tbl_MarketDetails
-MarketItemName

The relationship looks like this:
tbl_MarketDetails (one) ------ (many) tbl_Marketing , (enforce
referential integrity - ticked ) , (join type - rows in both tables equal)

tbl_Marketing (one) ------ (many) tbl_customer , (enforce referential
integrity - ticked ) , (join type - rows in both tables equal)

Problem: I created a query with all the 3 table fields in this query where
a
form (frm_newcustomer) is linked. It does not work in terms of allowing me
to save new entries in the form. I get the following message:
"You cannot add or change a record because a related record is required in
table 'tbl_Marketing' "
I don't understand - every field from the 3 tables is accounted for in the
query.

Nov 13 '05 #2
To add a record to tbl_Customer you need a record in tbl_Marketing that has
a value in the field joining the two tables that matches the value you are
entering in the joined field (on the tbl_Customer side of the join) for the
new record in tbl_Customer.

--
Wayne Morgan
MS Access MVP
"Gary T." <g4****@hotmail.com> wrote in message
news:43***********************@news.optusnet.com.a u...
I have 3 tables:

tbl_customer
-CustID
-fkeyMarketingID
-CompName
-CompAddr
-ContactName
-ContactAddr
-Ph
-Fax

tbl_Marketing
-MarketingID
-fkeyMarketItemID
-MarketQty
-MarketDateSent

tbl_MarketDetails
-MarketItemName

The relationship looks like this:
tbl_MarketDetails (one) ------ (many) tbl_Marketing , (enforce
referential integrity - ticked ) , (join type - rows in both tables equal)

tbl_Marketing (one) ------ (many) tbl_customer , (enforce referential
integrity - ticked ) , (join type - rows in both tables equal)

Problem: I created a query with all the 3 table fields in this query where
a
form (frm_newcustomer) is linked. It does not work in terms of allowing me
to save new entries in the form. I get the following message:
"You cannot add or change a record because a related record is required in
table 'tbl_Marketing' "
I don't understand - every field from the 3 tables is accounted for in the
query.

Nov 13 '05 #3
It's still not working.
Basically trying to use the frm_NewCustomer to enter info on new customers.
Customer A could have the following record of sent material (a subform of
tbl_marketing).
MarketItemName MarketQty MarketDateSent
BrochureA 9 9/9/05
SampleC 6 10/6/05
BrochureE 5 10/6/05

I have now simply placed all the marketing in one table:

tbl_Marketing
-MarketingID
-MarketItemName
-MarketQty
-MarketDateSent

Somehow this won't work as I think i still need to separate the
MarketItemname in its own table to
allow me to have a record of different materials sent at different dates per
customer.
I did this before as mentioned in my last post but no success.


"Wayne Morgan" <co***************************@hotmail.com> wrote in message
news:R8**************@newssvr12.news.prodigy.com.. .
To add a record to tbl_Customer you need a record in tbl_Marketing that has a value in the field joining the two tables that matches the value you are
entering in the joined field (on the tbl_Customer side of the join) for the new record in tbl_Customer.

--
Wayne Morgan
MS Access MVP
"Gary T." <g4****@hotmail.com> wrote in message
news:43***********************@news.optusnet.com.a u...
I have 3 tables:

tbl_customer
-CustID
-fkeyMarketingID
-CompName
-CompAddr
-ContactName
-ContactAddr
-Ph
-Fax

tbl_Marketing
-MarketingID
-fkeyMarketItemID
-MarketQty
-MarketDateSent

tbl_MarketDetails
-MarketItemName

The relationship looks like this:
tbl_MarketDetails (one) ------ (many) tbl_Marketing , (enforce
referential integrity - ticked ) , (join type - rows in both tables equal)
tbl_Marketing (one) ------ (many) tbl_customer , (enforce referential integrity - ticked ) , (join type - rows in both tables equal)

Problem: I created a query with all the 3 table fields in this query where a
form (frm_newcustomer) is linked. It does not work in terms of allowing me to save new entries in the form. I get the following message:
"You cannot add or change a record because a related record is required in table 'tbl_Marketing' "
I don't understand - every field from the 3 tables is accounted for in the query.


Nov 13 '05 #4
What are the names of each table, the fields in those tables, and which
fields the tables are linked on?

--
Wayne Morgan
MS Access MVP
"Gt394" <g4****@hotmail.com> wrote in message
news:43***********************@news.optusnet.com.a u...
It's still not working.
Basically trying to use the frm_NewCustomer to enter info on new
customers.
Customer A could have the following record of sent material (a subform of
tbl_marketing).
MarketItemName MarketQty MarketDateSent
BrochureA 9 9/9/05
SampleC 6 10/6/05
BrochureE 5 10/6/05

I have now simply placed all the marketing in one table:

tbl_Marketing
-MarketingID
-MarketItemName
-MarketQty
-MarketDateSent

Somehow this won't work as I think i still need to separate the
MarketItemname in its own table to
allow me to have a record of different materials sent at different dates
per
customer.
I did this before as mentioned in my last post but no success.


"Wayne Morgan" <co***************************@hotmail.com> wrote in
message
news:R8**************@newssvr12.news.prodigy.com.. .
To add a record to tbl_Customer you need a record in tbl_Marketing that

has
a value in the field joining the two tables that matches the value you
are
entering in the joined field (on the tbl_Customer side of the join) for

the
new record in tbl_Customer.

--
Wayne Morgan
MS Access MVP
"Gary T." <g4****@hotmail.com> wrote in message
news:43***********************@news.optusnet.com.a u...
>I have 3 tables:
>
> tbl_customer
> -CustID
> -fkeyMarketingID
> -CompName
> -CompAddr
> -ContactName
> -ContactAddr
> -Ph
> -Fax
>
> tbl_Marketing
> -MarketingID
> -fkeyMarketItemID
> -MarketQty
> -MarketDateSent
>
> tbl_MarketDetails
> -MarketItemName
>
> The relationship looks like this:
> tbl_MarketDetails (one) ------ (many) tbl_Marketing , (enforce
> referential integrity - ticked ) , (join type - rows in both tables equal) >
> tbl_Marketing (one) ------ (many) tbl_customer , (enforce referential > integrity - ticked ) , (join type - rows in both tables equal)
>
> Problem: I created a query with all the 3 table fields in this query where > a
> form (frm_newcustomer) is linked. It does not work in terms of allowing me > to save new entries in the form. I get the following message:
> "You cannot add or change a record because a related record is required in > table 'tbl_Marketing' "
> I don't understand - every field from the 3 tables is accounted for in the > query.
>
>



Nov 13 '05 #5
See my first post in the thread discussions. All the tables/fields are
listed and the join relationships described.
"Wayne Morgan" <co***************************@hotmail.com> wrote in message
news:yU*****************@newssvr14.news.prodigy.co m...
What are the names of each table, the fields in those tables, and which
fields the tables are linked on?

--
Wayne Morgan
MS Access MVP
"Gt394" <g4****@hotmail.com> wrote in message
news:43***********************@news.optusnet.com.a u...
It's still not working.
Basically trying to use the frm_NewCustomer to enter info on new
customers.
Customer A could have the following record of sent material (a subform of tbl_marketing).
MarketItemName MarketQty MarketDateSent
BrochureA 9 9/9/05
SampleC 6 10/6/05
BrochureE 5 10/6/05

I have now simply placed all the marketing in one table:

tbl_Marketing
-MarketingID
-MarketItemName
-MarketQty
-MarketDateSent

Somehow this won't work as I think i still need to separate the
MarketItemname in its own table to
allow me to have a record of different materials sent at different dates
per
customer.
I did this before as mentioned in my last post but no success.


"Wayne Morgan" <co***************************@hotmail.com> wrote in
message
news:R8**************@newssvr12.news.prodigy.com.. .
To add a record to tbl_Customer you need a record in tbl_Marketing that

has
a value in the field joining the two tables that matches the value you
are
entering in the joined field (on the tbl_Customer side of the join) for

the
new record in tbl_Customer.

--
Wayne Morgan
MS Access MVP
"Gary T." <g4****@hotmail.com> wrote in message
news:43***********************@news.optusnet.com.a u...
>I have 3 tables:
>
> tbl_customer
> -CustID
> -fkeyMarketingID
> -CompName
> -CompAddr
> -ContactName
> -ContactAddr
> -Ph
> -Fax
>
> tbl_Marketing
> -MarketingID
> -fkeyMarketItemID
> -MarketQty
> -MarketDateSent
>
> tbl_MarketDetails
> -MarketItemName
>
> The relationship looks like this:
> tbl_MarketDetails (one) ------ (many) tbl_Marketing , (enforce
> referential integrity - ticked ) , (join type - rows in both tables

equal)
>
> tbl_Marketing (one) ------ (many) tbl_customer , (enforce

referential
> integrity - ticked ) , (join type - rows in both tables equal)
>
> Problem: I created a query with all the 3 table fields in this query

where
> a
> form (frm_newcustomer) is linked. It does not work in terms of
allowing me
> to save new entries in the form. I get the following message:
> "You cannot add or change a record because a related record is
required in
> table 'tbl_Marketing' "
> I don't understand - every field from the 3 tables is accounted for
in the
> query.
>
>



Nov 13 '05 #6
Ok, so this "subform" you are entering the new customer in is based on the
tbl_Customer table? Also, in your original message you list tbl_Marketing
with a fkeyMarketItemID field, but you don't show a table where this is the
primary key field.

When entering a new customer, the value for fkeyMarketingID that is entered
(or not entered, i.e. Null) will have to exist in tbl_Marketing in the
MarketingID field.

Also, you say that this "subform" is "a subform of tbl_marketing". Are you
doing this with a form or a sub datasheet directly in the table? Have you
set the Parent/Child link fields for the form/subform setup?

The advantage of separating the MarketItemName into a separate table would
be to use a combo box on the form to "lookup" the name of the item instead
of having to type it in all of the time. You would then need a form to keep
this table up to date. Another option would be to base the Row Source of the
combo box on this field in the tbl_Marketing table and just add a new item
when needed. You would query the field so that duplicates would be hidden.
The combo box will then show you each item that already exists and you would
add new items when needed just by typing them in if you didn't find them in
the list.

Example Row Source:
SELECT DISTINCT MarketItemName FROM tbl_Marketing ORDER BY MarketItemName;

--
Wayne Morgan
MS Access MVP
"Gt394" <g4****@hotmail.com> wrote in message
news:43**********************@news.optusnet.com.au ...
See my first post in the thread discussions. All the tables/fields are
listed and the join relationships described.

Nov 13 '05 #7

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

Similar topics

4
by: Chris Strug | last post by:
Hi, Probably a very simple question but I'm afraid my experience at this is somewhat limited so... In a database with a many to one relationship, say orders to customers, is it preferable to...
28
by: Jeff Lanfield | last post by:
Suppose I have users that can belong to organizations. Organizations are arranged in a tree. Each organization has only one parent organization but a user maybe a member of multiple organizations....
6
by: Phil M | last post by:
I have two tables: Persons and Households, in a many-to-one relationship (many persons in one household). Persons has householdID as FK. The problem is that I want my form to use Persons as the...
0
by: David | last post by:
Hi, I have the following Tables: JS_Customer JS_Job JS_Product JS_Pack The layout:
4
by: Melissa | last post by:
I have a frontend file named CustomerApp and backend file named CustomerData. CustomerApp is at C:\Customer Database and CustomerData is at S:\Customer Database. Could someone help me with the code...
2
by: Phil | last post by:
I am learning Access, and have one question on relationships. How does one handle establishing a relationship that could be one-to-many, going either way between two tables? Example: One table...
3
by: lorirobn | last post by:
Hello, I have a report which uses a subreport. When I run the report, I get "Enter Parameter Value" error message for "tblGuestRoom". I click ok and the report seems to work fine. I...
4
by: Sasha | last post by:
Hi everyone, What is the best way to implement many-to-many relationship between objects? Any examples or links are welcome! Thank you, Sasha
7
by: Ron | last post by:
Hi All, Using Access2000, winXP. Table 1 = tblClients displayed on frmClients via qryClients. 2nd table = tblInvoices shown on frmInvoices via qryInvoices. 2nd table = tblDetails shown on...
5
by: Yitzak | last post by:
Hi after adding a field to a table through VBA How do I create a foreign key constraint/relationship between this field and a field in another table - and enforce referential integrity through...
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: 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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...

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.