473,396 Members | 1,996 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,396 software developers and data experts.

Error Message - "You can not add or change a record..."

6
Hi All,

Similar to many other posters, I don’t have a lot of experience with access (I'm using access 2003) and know little of VB, although I have picked up a bit while working on this project.

Here’s the set up. We receive many “little” shipments of four different versions of something. We combine these into one “big” shipment which we send out to be processed and want a total of each version in the big shipment.

Currently I have one main form for the big shipments, based off of the “big shipment” table and a subform, based off of a query. In the subform, the user selects the little shipments to be included in the big shipment from a combo box. Then the number of each version, for each little shipment, auto-fill and I get a grand total of each. I had everything working fine. I closed the program, without, I thought, making any changes (although obviously I did and saved them) shut down the computer, came back to work the next day, and when I selected a shipment from the combo box, I got the message

“You can not add or change a record because a related record is required in table ‘Big Shipments.’”

I’ve scoured my work and can’t figure out the problem, although I am sure it’s staring me in the face. None of my variables have a default of 0 and the link between the subform and main form is “RichardID.” Below are my tables and the query I used. There is a 1 to many relationship between both “little shipments” and “big shipments” and the table “line Items.” FYI- there are more tables, these are just the ones on this form.

Table 1 –Little Shipments
ShipmentID (key)
CtyShipID
CountyCode
CountyShipdate
RecievedDate
CHAs
NCHAs
OldCHAS
Refs

Table 2 – Big Shipments
RichardID (key)
TrackingNum
SentDate

Table 3 – Line Items
RichardID
ShipmentID

Query Shipment details:
SELECT [Line Items].ShipmentID, [Line Items].RichardID, [Little Shipments].CHAs, [Little Shipments].NCHAs, [Little Shipments].Refs, [Little Shipments].OldCHAs FROM [Little Shipments] RIGHT JOIN [Line Items] ON [Little Shipments].ShipmentID=[Line Items]. ShipmentID;

If you need more information, please tell me. I can’t think of anything else that might be relevant. Is my set-up correct (I wasn't sure about a line items table, but couldn't figure out any other way to set this up without repeating variables)? My query, a setting I have set to yes instead of no?

Thanks in advance for any help.

-Chezza
Nov 9 '07 #1
6 3214
ADezii
8,834 Expert 8TB
Please define your Relationships between the Tables and the Key(s) involved.
Nov 9 '07 #2
NeoPa
32,556 Expert Mod 16PB
Nicely laid out question Chezza. The one piece of info that is critical and missing though, is what ADezii asked for in his post.
Have you used the Relationships window to define links between tables?
We need to know the precise details of that.
Nov 13 '07 #3
Chezza
6
Hi,

Sorry about the dely in responding, I was pulled away from work earlier than expected.

After taking another look at the relationship table, I de-checked the referential integrity on both relationships (described below) and now it works perfectly. My question now, is why? I thought RF was supposed to insure I didn't enter a value in to a foreign key unless it existed as a primary key in another table.



Relationship Info:
There is a one to many relationship between "little shipments" and "line items" - Shipment ID is the key in "little shipments" and the FK in "line items."

The exact same thing is set up for "big shipments" and "line items".

I did forget include a column when I typed out the tables. "Line items" has an autonumber for a PK.

Thanks so much for pointing me in the right direction!
Nov 13 '07 #4
ADezii
8,834 Expert 8TB
Hi,

Sorry about the delay in responding, I was pulled away from work earlier than expected.

After taking another look at the relationship table, Ide-checked the referential integrity on both relationships (described below) and now it works perfectly. My question now, is why? I thought RF was supposed to insure I didn't enter a value in to a foreign key unless it existed as a primary key in another table.



Relationship Info:
There is a one to many relationship between "little shipments" and "line items" - Shipment ID is the key in "little shipments" and the FK in "line items."

The exact same thing is set up for "big shipments" and "line items".

I did forget include a column when I typed out the tables. "Line items" has an autonumber for a PK.

Thanks so much for pointing me in the right direction!
After taking another look at the relationship table, Ide-checked the referential integrity on both relationships (described below) and now it works perfectly. My question now, is why? I thought RF was supposed to insure I didn't enter a value in to a foreign key unless it existed as a primary key in another table.
It's exactly as you describe in that RI ensures that there can be no 'Orphaned' Records, namely a Record in a Child Table that has no matching Record in a Parent Table via the Primary Key(s) link. I'm not sure as to the 'why' but you may have solved a problem while opening the door to another. As it stands now, you can enter a Line Items Record with no corresponding Record (Parent) in Little Shipments. See what I mean?
Nov 13 '07 #5
Chezza
6
Yes, I completely understand what you are saying.

I was going to say, it doesn't matter because the only way one can enter information into the line items table is from the combo box on the form. But I was irked that I would then have a DB set up poorly. I rebuilt it anew, and it works perfectly, even with the RI. This was my first attempt at a DB in 5-6 years, so I made many mistakes during the building process and probably tweaked something on accident while learning.

Thanks for your help.
Nov 14 '07 #6
ADezii
8,834 Expert 8TB
Yes, I completely understand what you are saying.

I was going to say, it doesn't matter because the only way one can enter information into the line items table is from the combo box on the form. But I was irked that I would then have a DB set up poorly. I rebuilt it anew, and it works perfectly, even with the RI. This was my first attempt at a DB in 5-6 years, so I made many mistakes during the building process and probably tweaked something on accident while learning.

Thanks for your help.
It's all part of the learning process.
Nov 14 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Nick | last post by:
How to change the pic to a "show error" image when loading images failed - for example, no image file exists? I tried to add the following statement in the onload event function: if...
2
by: John A. | last post by:
I've received this error several times, and have only been able to get around it by deleting the offending form(s) and importing them from backup - Here's the sequence: 1. I'm editing a form or...
4
by: barbara_dave | last post by:
Hi all, We have a Access database used by multiple user. For some reason the database get a "Error" record. When doing search or record pointer point to this record, we get run time error...
4
by: indhu | last post by:
Hi i am getting this kind of error while saving the records this error comes. runtime error: you cannot add or change a record because a related record is required in table scene Private Sub...
6
by: JHNielson | last post by:
This is a very simple question.... I have a form that looks up Records for an unbound drop-down list. It has worked just fine up until last night. Now the button on the form to delete a record...
1
by: Sizo | last post by:
hey people, can you help me out here. How do i replace the message that is produced by MS Access when you click the delete record button. The message "You are about to delete one message" I would...
1
by: paulw4 | last post by:
I have the code below to run a query, that is created from a "fill in the blanks" form. I am now getting the error "You cancelled the previous operation" Earlier when I got this I closed the...
2
nirmalsingh
by: nirmalsingh | last post by:
hai all, i have created a website in asp.net c#. when i created a virtual directory and try ti run it i get the following error, You are unauthorised to view this page. How to resolve this? Thanx...
1
by: 2desperate2usedesperate | last post by:
ERROR: You do not have SELECT privileges on sys.V_$PARAMETER view. This process cannot proceed. Hello, I am using ORACLE 10g Standard Edition and I am trying to configure the Oracle Designer for...
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: 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
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.