Solved

ODBC Calls Faile

Posted on 2013-12-20
11
474 Views
Last Modified: 2013-12-21
I am sure this is an obvious one, but for some reason everything I try is not working.

I have an Access front-end with a SQL back-end connected via ODBC.

I have a form with multiple sub-forms.

When I add a new parent record one of the related tables throws:

ODBC--call failed. Cannot insert the value NULL into column 'link to parent'  column does not allow nulls. Insert fails. (#515) The statement has been terminated. (#3621)

The parent table has a RecordID (PK, int, not null) as a key. The related table (bound to the subform) has a RecordIDLink (PK, FK, int, not null)

I had what I thought were correct database diagrams where I set it for Cascading events, etc.

When this error started popping up I deleted the diagrams and reconnected to the linked tables. I even tried to use an append query to add the related record as soon as I go to a new record and that is still throwing the error.

Please help!!!

Thanks Experts.
0
Comment
Question by:Ei0914
  • 5
  • 5
11 Comments
 
LVL 30

Expert Comment

by:hnasr
ID: 39732918
Check main form alone.
Then add one sub form at a time and try.

If you can send sql to create the tables, then upload the access database sample.
0
 

Author Comment

by:Ei0914
ID: 39732938
Hi thank you for responding. I actually know which sub-form is the culprit and which table is causing this.  I link the subform to the main form with the field in question which means it should automatically be populating that field based on the value on the parent form. It almost seems that despite the fact that when I add a new record and force a save so the autonumber is generated that the related table represented by this particular subform is being updated before the autonumber exists. Does that seem possible??
0
 
LVL 30

Expert Comment

by:hnasr
ID: 39732958
Autonumber is used in main table, other related tables should use a number field, not Autonumber to link with parent tables field..
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:Ei0914
ID: 39732961
That's exactly right. The related table has a numeric field linked to the parent autonum.
0
 
LVL 30

Expert Comment

by:hnasr
ID: 39732982
Fine.
Compare between the problem table and other working one.

If you can, try to help me in reproducing the issue.
0
 

Author Comment

by:Ei0914
ID: 39732998
There are 6 subforms on the main form -- all related by a numeric field linked to the parent autonum field.

When I click Add new on the parent form I go to a new record, force a save to generate the autonum (which is displayed on the form so I can watch when it gets generated) and before it displays I get the OBDC error -- which tells me that somehow the subform is adding the record before the parent record is saved.

That is the issue. Not sure what else you need in order to assist me. I can't backup the SQL tables because the data is proprietary and stored on my client's server.
0
 
LVL 30

Expert Comment

by:hnasr
ID: 39733012
Since you know the issue, I expect you to recreate it using dummy tables reflecting the structure of the original tables populated with dummy info.

Doing that might lead you to the solution.
0
 

Author Comment

by:Ei0914
ID: 39733017
I see. If I were to do that using Access tables I will not get the ODBC errors. Maybe someone else has had this problem in the past who can help me. Thanks a lot.
0
 
LVL 30

Expert Comment

by:hnasr
ID: 39733034
"I see. If I were to do that using Access tables I will not get the ODBC errors"
I mean to do that using the same environment.

"Thanks a lot."
Welcome!
0
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
ID: 39733513
force a save to generate the autonum (which is displayed on the form so I can watch when it gets generated)
Is tihs just for testing, or is this something that is done in the live version of the app?

Are you running code in the Subform at any point? The error you're getting indicates that a record is Dirty in that subform, and Access is trying to save it.

Are you absolutely sure that you've properly set the Master and Child links for that subform? Check those, then check them again.

I've had troubles similar to this with linked SQL tables, and in those cases I've had to delete the linked table, and then add it back. I had to make sure the SQL table had a PK defined on it, and that the PK was carried over to the Access link. You can view the Indexes of a linked table by opening that linked table in design view, and reviewing the Indexes.
0
 

Author Closing Comment

by:Ei0914
ID: 39733756
I'm an idiot! On the subform I recently did make a change to force a save because that subform has a subform on it as well.... Geez.... no wonder it just started happening. I had completely forgotten about that.

Thanks LSM!!!
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question