Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ODBC Calls Faile

Posted on 2013-12-20
11
Medium Priority
?
496 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
11 Comments
 
LVL 31

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 31

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
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 

Author Comment

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

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 31

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 31

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 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 2000 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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

705 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