Using ADO to write an Insert then Update Query

TJBernard

Registered User.
Local time
Today, 08:33
Joined
Mar 28, 2002
Messages
176
I am new to ADO so any advice I can receive would be very beneficial.

I have code the runs correctly in DAO, but I am having trouble converting the code to ADO. On the click of a button I am updating a record into Table1 and then inserting a record into Table2. I have tried some code, and I have been able to get the Update Query to run correctly, but when the Insert Query starts I get the error "ODBC Call Failed".

If anyone has any ideas or information please let me know. I can post the code I have tried if it is helpful in resolving my issue.

Thank you for your time,

T.J.
 
If you are using MS Access data tables, there is no reason to convert DAO to ADO.

If it hurts, don't do it.

RichM
 
This is the basic select into a recordset code
Dim db As New ADODB.Connection
Dim rs1 As New ADODB.Recordset
Set db = CurrentProject.Connection
strSQL = "SELECT MyField1, MyField2 " & _
"FROM MyTable " & _
"WHERE MyField2 = 'Testing' "
Set rs1 = db.Execute(strSQL)
Processing
rs1.Close
Set db = nothing

This is basic Insert/Update/Delete
Dim db As New ADODB.Connection
Set db = CurrentProject.Connection
strSQL = "INSERT INTO MyTable "
strSQL = strSQL & "(MyField1,MyField2,MyField3) "
strSQL = strSQL & "Values ('Value1',1234.567,#01/20/2003#)"
db.Execute (strSQL)
Set db = nothing

Just the actual SQL is different
 

Users who are viewing this thread

Back
Top Bottom