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

rst.update: run-time error -2147217887(80040e21), ODBC-call failed

Dear Expert,

Im using SQL server (2000) as my backend and MS Access (2000) as F.E..

I use two data entry froms to add new records, form1 to enter details of delivery (tbldelivery) and form2 to enter details of delivery items (tbldeliveryitem). Previously everything is fine, but about 2 weeks ago an error message keeps popping out "run-time error -2147217887(80040e21), ODBC -call failed" after I add one delivery record and tried to add the detail of delivery items (one-to-many).

The situation is:
(1) I got no problem with entering new delivery record,
(2) But everytime I have one new delivery record added by form1, I have to restart the database to add an delivery item record, otherwise, the above error message occurs at rst.update
(3) I can manually input a new delivery item record.

The problematic part of the code as follwoing:

/ Function Save()


Dim rst As ADODB.Recordset
Dim x As Integer
Dim rst3 As ADODB.Recordset
Set rst = New ADODB.Recordset
rst.ActiveConnection = CurrentProject.Connection
Set rst3 = New ADODB.Recordset

rst3.ActiveConnection = CurrentProject.Connection

rst.CursorType = adOpenKeyset
rst.LockType = adLockOptimistic
rst.Open "select * from dbo_tblDelivery_items"

rst.MoveLast
x = rst!DeliveryItem_ID

rst.AddNew

rst!DeliveryItem_ID = x + 1
rst!Delivery_No = Delivery_No
rst!Product_ID = Product_ID
rst!Short_name = Short_name
rst![Type/Model] = [Type/Model]
rst!SerialNumber = SerialNumber
rst!RadioModuleSerialNo = RadioModuleSerialNo
rst!Radio_Power = Radio_Power
rst!Solar_or_mains = Solar_or_mains
rst!Box_SerialNo = Box_SerialNo
rst!Firmware_Version = Firmware_Version
rst!Hardware_Version = Hardware_Version
rst!Manufacture_Date = Manufacture_Date
rst!Comments = Comments
rst!Actions = Actions
rst!Action_date = Action_date

rst.Update
rst.Close
Set rst = Nothing

End Function /

Please help me in this regard..Please..

Many thanks.

kindest regards, Jay
Apr 21 '08 #1
5 9811
ADezii
8,834 Expert 8TB
Dear Expert,

Im using SQL server (2000) as my backend and MS Access (2000) as F.E..

I use two data entry froms to add new records, form1 to enter details of delivery (tbldelivery) and form2 to enter details of delivery items (tbldeliveryitem). Previously everything is fine, but about 2 weeks ago an error message keeps popping out "run-time error -2147217887(80040e21), ODBC -call failed" after I add one delivery record and tried to add the detail of delivery items (one-to-many).

The situation is:
(1) I got no problem with entering new delivery record,
(2) But everytime I have one new delivery record added by form1, I have to restart the database to add an delivery item record, otherwise, the above error message occurs at rst.update
(3) I can manually input a new delivery item record.

The problematic part of the code as follwoing:

/ Function Save()


Dim rst As ADODB.Recordset
Dim x As Integer
Dim rst3 As ADODB.Recordset
Set rst = New ADODB.Recordset
rst.ActiveConnection = CurrentProject.Connection
Set rst3 = New ADODB.Recordset

rst3.ActiveConnection = CurrentProject.Connection

rst.CursorType = adOpenKeyset
rst.LockType = adLockOptimistic
rst.Open "select * from dbo_tblDelivery_items"

rst.MoveLast
x = rst!DeliveryItem_ID

rst.AddNew

rst!DeliveryItem_ID = x + 1
rst!Delivery_No = Delivery_No
rst!Product_ID = Product_ID
rst!Short_name = Short_name
rst![Type/Model] = [Type/Model]
rst!SerialNumber = SerialNumber
rst!RadioModuleSerialNo = RadioModuleSerialNo
rst!Radio_Power = Radio_Power
rst!Solar_or_mains = Solar_or_mains
rst!Box_SerialNo = Box_SerialNo
rst!Firmware_Version = Firmware_Version
rst!Hardware_Version = Hardware_Version
rst!Manufacture_Date = Manufacture_Date
rst!Comments = Comments
rst!Actions = Actions
rst!Action_date = Action_date

rst.Update
rst.Close
Set rst = Nothing

End Function /

Please help me in this regard..Please..

Many thanks.

kindest regards, Jay
  1. What function does the rst3 Recordset serve in the above code?
  2. Is Form1 closed when you are adding delivery items to tblDeliveryItem via Form2? If it isn't try closing it, then add the related Records.
Apr 22 '08 #2
  1. What function does the rst3 Recordset serve in the above code?
  2. Is Form1 closed when you are adding delivery items to tblDeliveryItem via Form2? If it isn't try closing it, then add the related Records.

Dear ADezii

Thank you very much for your reply.

(1) I am sorry for confusing you by the rst3. It is used to copy field "deliveryNo" in tblDelivery into the second tblDeliveryItem, which is the link between two tables. Some key fields in the two tables are:

tblDelivery

delivery_ID (Autonumber)
delivery_No (text)
deliveryDestination_ID (number)
DeliveryDestination (text)
....

tbleDeliveryItems

deliveryItem_ID (autonumber)
delivery_NO(text)
Product_ID
ProductDescription

....

(2) I am quite sure form1 is closed as I used a command button to link the two forms. When that command button is clicked, a messsage asks "do you want to close this form to add a delivery item?" if yes, close the form1 and open form2. If no then just close form1.

anything wrong with closing recordset or ODBC link?

Many thanks.

Jay
Apr 22 '08 #3
ADezii
8,834 Expert 8TB
Dear ADezii

Thank you very much for your reply.

(1) I am sorry for confusing you by the rst3. It is used to copy field "deliveryNo" in tblDelivery into the second tblDeliveryItem, which is the link between two tables. Some key fields in the two tables are:

tblDelivery

delivery_ID (Autonumber)
delivery_No (text)
deliveryDestination_ID (number)
DeliveryDestination (text)
....

tbleDeliveryItems

deliveryItem_ID (autonumber)
delivery_NO(text)
Product_ID
ProductDescription

....

(2) I am quite sure form1 is closed as I used a command button to link the two forms. When that command button is clicked, a messsage asks "do you want to close this form to add a delivery item?" if yes, close the form1 and open form2. If no then just close form1.

anything wrong with closing recordset or ODBC link?

Many thanks.

Jay
Hello Jay, prior to closing Form1, and after Updating the Recordset that adds a Record to tblDelivery, Requery the Rercordset as in:
Expand|Select|Wrap|Line Numbers
  1. <Your Recordset Name>.Requery
It's a long shot, but it may be a case where SQL Server is not properly Updating tblDelivery, and when you attempt to Add a Record to the Child Table (tblDeliveryItems), it sees it as adding an Orphan Record. Like I said, a long shot.
Apr 22 '08 #4
Hello Jay, prior to closing Form1, and after Updating the Recordset that adds a Record to tblDelivery, Requery the Rercordset as in:
Expand|Select|Wrap|Line Numbers
  1. <Your Recordset Name>.Requery
It's a long shot, but it may be a case where SQL Server is not properly Updating tblDelivery, and when you attempt to Add a Record to the Child Table (tblDeliveryItems), it sees it as adding an Orphan Record. Like I said, a long shot.
Hi ADezii,

I have added the code something like:

rst.update
rst.requery
rst.close

but I got another similar error message after waiting for about 1 minutes, "run-time error '-2147467259(80004005)' ODBC-call failed". Without that code, no problem in adding a new delivery record.

Any further help? Many thanks.

Regards, Jay
Apr 22 '08 #5
Hi ADezii,

I have added the code something like:

rst.update
rst.requery
rst.close

but I got another similar error message after waiting for about 1 minutes, "run-time error '-2147467259(80004005)' ODBC-call failed". Without that code, no problem in adding a new delivery record.

Any further help? Many thanks.

Regards, Jay
I have found the answer. Nothing wrong with my code, it is the primary keys of the two tables in SQL. By creating two similar tables, I have managed to get everything back to normal. Many thanks anyway.

Jay
Apr 25 '08 #6

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

Similar topics

13
by: Nigel J. Andrews | last post by:
This will be a little vague, it was last night and I can't now do the test in that db (see below) so can't give the exact wording. I seem to remember a report a little while ago about tsearch v2...
0
by: Jamey | last post by:
I perused old posts for an answer to this for at least an hour, and I've found a work-around, but no definitive answer. Synopsis of the problem: On NotInList or ctl.Requery commands where a...
3
by: bill_hounslow | last post by:
I'm trying to transfer data from one Sql Server into a table on another, using a simple INSERT query in an Access database with links to tables on both servers (the reasons for this are complicated...
1
by: c_del29 | last post by:
I am getting this message every time that I open an e-mail in Outlook or hotmail. Microsoft Visual C++ Runtime Error! Program: c:\Program Files\Internet Explorer\IEXPLORE.EXE This application...
2
by: kl | last post by:
Hello My aspx pages run fine with non-secure server. When I tried to run them with https://, on the browser side, the runtime error occurred with suggestions of adding the following configuration...
0
by: Sean OConnor | last post by:
I have three servers, public web server (e.g. web1), file server (file1), and web services server (service1). web1 is in the DMZ and file1 and service1 are internal. I'm calling the webservices...
8
by: g_man | last post by:
I am trying trap Runtime error 3022 (duplicates) in the click event of a command button that closes the form. I have code in the Form_Error event that does a good job of providing a more meaningful...
5
by: shivaniem | last post by:
Please help me on this. I want ti add detatils in my database through VB6. when i rumn the program i say add enter the details and say save. when i say save an error occurs saying Runtime...
8
by: tgit | last post by:
Hi, I have moved application from windows 2000 to xp platform. I am using Access 2003. I am getting the error during a insert operation on table. Error: runtime error '-2147467259)' ODBC...
4
by: ielamrani | last post by:
Hi, I am getting this error when I try to export to an excel sheet. When I click on a button to export the first time it's fine, I rename the exported excel sheet and I try to export it again and I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.