Please help with ADO Code

  • Thread starter Thread starter Al
  • Start date Start date
A

Al

I am trying to rewrite the following code, using ADO instead but I am having
trouble with the ".New". I keep getting a message that ODBC---Call Failed.
Run Time Error '3146'. Then the code breaks at ".Update".
what would be the equivelent in ADO to the following snippet of code? My
front end is Access 2003 and my backend is sql Server 2005
thanks
Al




Dim db As Database, rst As Recordset
Set db = CurrentDb()
Set rst = db.OpenRecordset("tblUserLog", dbOpenDynaset,
dbSeeChanges, dbOptimistic)

With rst
.AddNew
![UserID] = Me![SelectUser]
.Update
End With
rst.Close
 
If you have references to both ADO and DAO or ODBC, then the Dim statements
might not be using the library you expect. It will use whichever library is
higher in the priority order. From the error message it sounds like you're
getting ODBC. You should disambiguate the references by including the
library name:
Dim db as ADODB.Database
Dim rst as ADODB.RecordSet

Before trying to run the code, make sure it all compiles successfully.
 
Back
Top