FindFirst with external db not working

G

Gibson

I use the following code to open an external db and try to find a matching
record in a table in that db with one I declared (Variable1). The problem
is an error tells me Operation not supported by object when I get to the
FindFirst operation. Is there an alternative or is my syntax wrong?
Thanks

strTableName = "Tbl1"
strDBName = "C:\Program Files\DB.MDB"
Set dbImp = DBEngine.Workspaces(0).OpenDatabase(strDBName, False,
True, "")

Set rst = dbImp.OpenRecordset(strTableName)
rst.FindFirst "Field1 = '" & Variable1 & "'"
 
J

John Vinson

I use the following code to open an external db and try to find a matching
record in a table in that db with one I declared (Variable1). The problem
is an error tells me Operation not supported by object when I get to the
FindFirst operation. Is there an alternative or is my syntax wrong?
Thanks

strTableName = "Tbl1"
strDBName = "C:\Program Files\DB.MDB"
Set dbImp = DBEngine.Workspaces(0).OpenDatabase(strDBName, False,
True, "")

Set rst = dbImp.OpenRecordset(strTableName)
rst.FindFirst "Field1 = '" & Variable1 & "'"

I believe the default Recordset type for the OpenRecordset method is a
Table type recordset - which only works on local tables.

Try

Set rst = dbImp.OpenRecordset strTableName, dbOpenDynaset

John W. Vinson[MVP]
 

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