Please help with ADO Code

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
 
P

Paul Shapiro

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top