BuilderSpec
Programmer
Hi
I have some code in a form that writes to an Access table. this is it below.
Dim rs As New ADODB.Recordset
Dim sqlstr As String
sqlstr = "select * from Employees where EmployeeID =" & i
rs.Open sqlstr, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
If Not rs.EOF Then
rs.Fields("OnNow") = True
rs.Fields("TimeLoggedOn") = Now()
rs.Update
End If
rs.Close
Set rs = Nothing
It works perfectly I am not after suggestions of how it can be optimized etc .
I have now changed the backend Employees table to be on a SQL Server and it is linked here. I can see the data in the table ok.
When this code runs it fails on the rs.Update code with "ODBC Call failed."
yet if from the Immediate window I type :
Docmd.runsql "update Employees set "... blah blah this works perfectly.
The reason I don't want to re-engineer all the code is that there is a huge amount of code that manually updates records in this way and would be tedious to change them all to docmd.runsql's. In some cases this would not be appropriate for the business logic anyway.
Anybody any idea why this code would fail when the data is clearly available and updateable ?
Pls...
Hope this helps!
Regards
BuilderSpec
I have some code in a form that writes to an Access table. this is it below.
Dim rs As New ADODB.Recordset
Dim sqlstr As String
sqlstr = "select * from Employees where EmployeeID =" & i
rs.Open sqlstr, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
If Not rs.EOF Then
rs.Fields("OnNow") = True
rs.Fields("TimeLoggedOn") = Now()
rs.Update
End If
rs.Close
Set rs = Nothing
It works perfectly I am not after suggestions of how it can be optimized etc .
I have now changed the backend Employees table to be on a SQL Server and it is linked here. I can see the data in the table ok.
When this code runs it fails on the rs.Update code with "ODBC Call failed."
yet if from the Immediate window I type :
Docmd.runsql "update Employees set "... blah blah this works perfectly.
The reason I don't want to re-engineer all the code is that there is a huge amount of code that manually updates records in this way and would be tedious to change them all to docmd.runsql's. In some cases this would not be appropriate for the business logic anyway.
Anybody any idea why this code would fail when the data is clearly available and updateable ?
Pls...
Hope this helps!
Regards
BuilderSpec