Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / March 2008

Tip: Looking for answers? Try searching our database.

Error when adding a new record to a form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ksto - 18 Mar 2008 22:06 GMT
I have a form [fInsurance] based on a query [qInsurance].  The query is based
on two tables [tVendors] and [tInsurance].  While the form will allow me to
update records, it will not allow me to save new records.  The new records
button is not grayed out so I can go to a new record and enter all the data.  
However, when I try to tab out of the new record, I get the error message
"You cannot add or change a record because a related record is required in
table "tInsurance".  

I have checked the properties of the form and Allow Additions is set to yes.
Any ideas on what the problem is?

Thanks to all of you gurus who spend your time helping people like me!
ruralguy - 19 Mar 2008 00:16 GMT
As the error states: you are not adding a record to the tInsurance table
which sounds like it is the Parent side of a Parent/Child relationship
between the two tables.

>I have a form [fInsurance] based on a query [qInsurance].  The query is based
>on two tables [tVendors] and [tInsurance].  While the form will allow me to
[quoted text clipped - 8 lines]
>
>Thanks to all of you gurus who spend your time helping people like me!

Signature

RuralGuy (RG for short) aka Allan Bunch MS Access MVP - acXP WinXP Pro
Please post back to this forum so all may benefit.

ksto - 19 Mar 2008 18:25 GMT
The tInsurance and tVendor tables have a one-to-one relationship, with
VendorID as the primary field in each table.  I then joined my tables
together with a query, on which the form is based.  Here are the options I'm
aware of:

1. Join tInsurance and tVendor into a single table
2. Split the form into form/subform with one based on each table

I guess my question is, is there any way to add records to both tables from
the form without changing the existing structure?

> As the error states: you are not adding a record to the tInsurance table
> which sounds like it is the Parent side of a Parent/Child relationship
[quoted text clipped - 12 lines]
> >
> >Thanks to all of you gurus who spend your time helping people like me!
ruralguy - 19 Mar 2008 20:09 GMT
Do you really have VendorID as the PK on *both* tables?  Is it an AutoNumber
in one of the tables?

>The tInsurance and tVendor tables have a one-to-one relationship, with
>VendorID as the primary field in each table.  I then joined my tables
[quoted text clipped - 12 lines]
>> >
>> >Thanks to all of you gurus who spend your time helping people like me!

Signature

RuralGuy (RG for short) aka Allan Bunch MS Access MVP - acXP WinXP Pro
Please post back to this forum so all may benefit.

ksto - 19 Mar 2008 20:18 GMT
No, it's not an autonumber.  VendorID is a text field imported from our old
database and used as the primary key in both tables.

> Do you really have VendorID as the PK on *both* tables?  Is it an AutoNumber
> in one of the tables?
[quoted text clipped - 15 lines]
> >> >
> >> >Thanks to all of you gurus who spend your time helping people like me!
ruralguy - 19 Mar 2008 20:38 GMT
I've not worked much with 1:1 relationships but you will undoubtedly need to
fill in the PK key of one of the tables yourself - and it looks like it is
the tInsurance table.  I would try using the BeforeUpdate event of the form
for this.

>No, it's not an autonumber.  VendorID is a text field imported from our old
>database and used as the primary key in both tables.
[quoted text clipped - 4 lines]
>> >> >
>> >> >Thanks to all of you gurus who spend your time helping people like me!

Signature

RuralGuy (RG for short) aka Allan Bunch MS Access MVP - acXP WinXP Pro
Please post back to this forum so all may benefit.

ksto - 19 Mar 2008 22:27 GMT
I think I figured it out:

I just went into Edit Relationship for the two tables and set "Cascade
update related fields" to yes.  It will now allow me to update and append
records to the two tables.

Thanks for your help - you got me thinking along the right lines!

> I've not worked much with 1:1 relationships but you will undoubtedly need to
> fill in the PK key of one of the tables yourself - and it looks like it is
[quoted text clipped - 9 lines]
> >> >> >
> >> >> >Thanks to all of you gurus who spend your time helping people like me!
ruralguy - 20 Mar 2008 00:17 GMT
That's great. Thanks for posting back with your success.

>I think I figured it out:
>
[quoted text clipped - 9 lines]
>> >> >> >
>> >> >> >Thanks to all of you gurus who spend your time helping people like me!

Signature

RuralGuy (RG for short) aka Allan Bunch MS Access MVP - acXP WinXP Pro
Please post back to this forum so all may benefit.

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.