473,513 Members | 2,583 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

cannot add or change a record because a related record is required

75 New Member
I have a subform with a combo box that will not add a record. The form's record source is tblRetreadDetails.
Expand|Select|Wrap|Line Numbers
  1. tblRetreadDetails structure:
  2. RetreadDetailsID     Autonumber, Primary key
  3. RetreadID            Number, foreign key to tblRetreads
  4. TireID               Number, foreign key to Tires table
  5. RetreadOptionsID     Number, foreign key to tblRetreadOptions
tblRetreadOptions structure:
RetreadOptionsID
Brand
Tread
Style
TreadDepth

The relationship is one(tblRetreadOptions) to many(tblRetreadDetails).

The combo's control source is RetreadOptionsID.
The combo's rowsource is:
Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCT tblRetreadOptions.RetreadOptionsID
  2.    , tblRetreadOptions.Tread
  3.    , tblRetreadOptions.Brand
  4.    , tblRetreadOptions.Style
  5.    , tblRetreadOptions.TreadDepth
  6. FROM tblRetreadOptions
  7. WHERE (((tblRetreadOptions.Brand)
  8.    =[forms]![frmRetreads]
  9.       ![frmRetreadDetails].[form]
  10.       ![cboRetreadBrand]))
  11. ORDER BY tblRetreadOptions.Tread;
When trying to add a record I get an error message:
"You cannot add or change a record because a related record is required in tblRetreadOptions".

The record is in the table or it would not be an option in the combo. What am I missing?
Thanks!
Dec 16 '13 #1
13 3830
zmbd
5,501 Recognized Expert Moderator Expert
What this means is that in the record you are editing the field [tblRetreadDetails ]![RetreadOptionsID] either doesn't have a value set or the value you have selected is not a valid. Given that only the valid values are showing then it's a setting in the control - most likely the bound column.

Go back into your CBO and make sure the BOUND column is set for the column that contains the [tblRetreadOptions]![RetreadOptionsID]
Dec 16 '13 #2
Knowlton
75 New Member
The bound column is 1. Column count is 5. Column widths are 0";1";1";0";0". I'm using columns 4 and 5 to populate other controls AfterUpdate. Limit To List is set to yes.

I'm unable to see anything different in the settings for this one than in numerous others I have.
Dec 16 '13 #3
zmbd
5,501 Recognized Expert Moderator Expert
Please check:

[tblRetreadDetails]![RetreadOptionsID]
Number, foreign key to tblRetreadOptions
verify this in database tools, table relationships

The combo's control source is
RetreadOptionsID.
verify that this is [tblRetreadDetails]![RetreadOptionsID]
and NOT [tblRetreadOptions]![RetreadOptionsID]
(I tend to name fields with..
tbl_exampletable
[exampletable_pk]
[exampletable_FK_relatedtable_pk]
or
[exampletable_FK_relatedtable]

I learned the hardway to not use the same field name in multiple tables; thus even if I use [PK] or [ID] in every table it's always prefaced with the table name. Took me two weeks to figure out why an embedded query kept failing and I had the wrong table/field referenced.

The combo's rowsource is:
[tblRetreadOptions]![RetreadOptionsID]
verfiy that this is actually the value being set in the bound column... easy, temporarily set widths from 0;1;1;0;0 to all 1" so that you can see the first value.
Dec 17 '13 #4
Knowlton
75 New Member
In the edit relationships window - table/query:tblRetreadOptions!RetrreadOptionsID
related table/query - tblRetreadDetails!RetreadOptionsID

Referential integrity is enforced with cascade update and delete.

The combos control source is tblRetreadDetails!RetreadOptionsID. The forms control source is tblRetreadDetails and not a query that includes tblRetrteadOptions.

For what it may or may not be worth, for a while now, I have been having problems with Access closing. If I open a file and only look at something or maybe print a report, when I close it, Access closes completely, but if I enter records and then close, the file closes but Access remains open and will only close by using the task manager to force it to close. I am using Access 2003.
Thanks a bunch for your help!
Dec 17 '13 #5
Knowlton
75 New Member
I forgot to mention that the value being set is the RetreadOptionsID number.
Dec 17 '13 #6
zmbd
5,501 Recognized Expert Moderator Expert
Tied up at the momement so let me digest things...

In the meantime: IFF you don't have a docmd.close in the on close events then it sounds like your installation is damaged beyond the basic repair.

I usually don't recommend this; however, you may be due for a complete un-install/re-install of the software.

Before you do this; make a new, blank database, import all of the items from the old database into the new database.
See if this fixes things...


If not... U/R-Install Office.

Once done, you'll need to run update to receive all of the critical updates. Or you can download the file from Microsoft here: Microsoft Office Service Pack 3 MAKE SURE YOU READ EVERYTHING ON THIS PAGE!

I can not stress enough the need to backup your harddrive, or at least the importaint files BEFORE you start anything. Gather all of your restore disks for the PC and be prepared to nuke and re-install on the rare oddball fatal event.
Dec 17 '13 #7
zmbd
5,501 Recognized Expert Moderator Expert
In the edit relationships window (...)
tblRetreadOptions!RetrreadOptionsID
I'm guessing this is a typo??
Dec 17 '13 #8
Knowlton
75 New Member
Yes that is a typo. Sorry
Dec 17 '13 #9
Knowlton
75 New Member
I had actually thought about recreating my form to see if that made any difference. It seems like I remember having some issues another time and just started over and everything worked fine.
Take time to do your work. I've got other things going on also so I'm not in a rush.
Dec 17 '13 #10
zmbd
5,501 Recognized Expert Moderator Expert
Ok
so
looking at what you've posted, I'm back down to something got broken.

1) Decompile option. Make the shortcut as given in this MS KB article: http://support.microsoft.com/kb/819780
However, Instead of altering the file's icon, I make a new shortcut on the desktop and enter the information.
Make a backup of the database you are working with and then drag and drop the copy on the new decompile.
Once open perform compact and repair
save the file
open using the "normal" method.

2) recreate the database using a new database file and then importing the tables etc...

3) complete U&R-Office. Down load the SP3 from MS first and follow the instructions in the download page.
Dec 17 '13 #11
Knowlton
75 New Member
I think you're right about something is broken. After reading through the article, I have experienced "Access has encountered a problem and needs to close".

I have a couple of questions for clarification.
1)I have a split database so do I do this for the data file, the program file or both?

2)You say to make the shortcut as given in the MS KB article. I didn't understand anything in it about a shortcut. I guess it may make sense as I go through it but the process makes me a bit nervous. I'm guessing the process is to repair the file(s) and then uninstall and reinstall Office so the file(s) don't damage Access?

Sorry for the trouble.
Dec 18 '13 #12
zmbd
5,501 Recognized Expert Moderator Expert
1) Unless the backend has anything other than tables it should be ok.

2) Sorry, that made sense in my head at the time.
a) You will need this information:
- msaccess.exe
- "drive\path\" to access
- /decompile
so for my install on a windows7(64b) it reads:
- msaccess.exe
- "C:\Program Files (x86)\Microsoft Office\Office14" (include the quotes for spaces and symbols)
- /decompile
b) right click on your desktop, new, shortcut
the wizard may open... enter just the path to msaccess and name it decompile - let it finish, if no wizard then enter the properties as follows.
c) find the shortcut on the desktop and right click - properties
shortcut tab
Target = msaccess.exe /decompile
Startin = "C:\Program Files (x86)\Microsoft Office\Office14"
(this is for me... you will need your location)
[apply]
things will alter just a tad, that's ok
[ok]
At this point the icon should change to the Access icon and the word "decompile" for the title.

YEA

Now make a copy of the frontend
Drag the copy on-top of the new decompile
the file should open.
1) compact and repair
2) vbe - compile
save the file


Open copy using the normal method. If all goes well then archive your original file, rename and backup the "repaired" copy.

Now if this works then you shouldn't need to do anything else... only if there continues to be wierdness with office/access would you need to go with the U/R-Office route. Before doing the U/R check that this is a problem with all of your database files not with just this one.

The reason I do this "decompile" with a desktop shortcut is that I do some heavy coding and testing; thus, I occationally get things fouled beyound the normal reboot the pc fix and it's a pain to keep going in and makeing the /decompile at the file level then remove it etc... (BTW: My 1st step in all troubleshooting, close everything, shutdown windows and pc, COLD boot - 90% "cure" rate. :)
Dec 18 '13 #13
Knowlton
75 New Member
Sorry for taking so long but I have been tied up with other things. Compact and repair made no difference. I found that I had added another reference to the RetreadOptions table because sometimes there is a different retread applied from what was requested and I wanted to track this. In adding that field, I neglected to remove the "0" default and that was causing the problem.
Thanks again for your help!
Jan 22 '14 #14

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

Similar topics

0
3183
by: elvin | last post by:
Okay - apologize in advance for the length, but I want to make sure all you knowledgeable and helpful people have all the details you need to hopefully point my newbie rear in the right direction....
4
4039
by: amywolfie | last post by:
I've been trying to do something for about 3 days – I get close, but not 100%. I am trying to: Open frmRevisionHistory from a button on frmFeeInput. If there is NO RELATED RECORD, then I...
6
10642
by: Aaron Smith | last post by:
Ok. I have a dataset that has multiple tables in it. In one of the child tables, I have a column that I added to the DataSet (Not in the DataSource). This column does not need to be stored in the...
0
1082
by: kesk | last post by:
Hi, I am a learner in vb.net who is designing a database project. I dont have formal vb.net training, i learned from database books only, to the most extent its good. I have seen on dbl-clicking...
0
3558
by: André | last post by:
Hi, Still the same (unsolved problem), but other error now. I have a detailsview for inserting data, and a dropdownlist which selectedValue must be used to fill one of the field of the...
2
3737
by: Bob Alston | last post by:
I have an application with several forms. Most forms use radio boxes for Yes/No choices. On a few of these, once one option is selected, the user cannot change the selection without moving to...
5
4990
AccessIdiot
by: AccessIdiot | last post by:
Argh! Just when I think everything is working and I am doing one final test before showing it to the guys I built the db for, Access throws out a weird message and won't let me add a record. But only...
2
3905
by: ApexData | last post by:
Access2000, using a continuous form. I’m getting a message that say “you cannot add or change a record because a related record is required in table Employee”. This occurs in all my combobox...
4
3087
by: PW | last post by:
Hi, I set up a relationship between two tables with the itineraryid fields in both tables: tblDailyItinerary tblDailyMeals I have a form that writes a record to tblDailyItinerary that...
15
3179
TheSmileyCoder
by: TheSmileyCoder | last post by:
I have a table of observations. This table is loaded as a recordset, and processed to be used in a Treeview control. Part of this process is to determine which icon to display for the record in...
0
7537
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...
1
7099
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5685
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,...
1
5086
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4746
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3233
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3222
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1594
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
456
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.