M
mharness
Hello,
I've been working with recordsets in access on an access backend and getting
by ok but I am now trying to work with some ms-sql tables on a remote server
that are linked to an access adp and am having a problem.
I can run the following code on access/access but when I try to run in on
access/ms-sql it errors out with "object variable or with block variable not
set". I assume that this is occurring because even after I set dbs =
currentdb, dbs still equals nothing but I don't know how to set it to
anything except the current database.
Thanks for any help,
Mike
Sub Test()
Dim dbs As Database
Dim qry As String
Dim rst As Recordset
Set dbs = CurrentDb
qry = "select fname from tblaccounts"
Set rst = dbs.OpenRecordset(qry, dbOpenDynaset)
While Not rst.EOF
Debug.Print rst!fname
rst.MoveNext
Wend
rst.Close
Set rst = Nothing
dbs.Close
Set dbs = Nothing
End Sub
I've been working with recordsets in access on an access backend and getting
by ok but I am now trying to work with some ms-sql tables on a remote server
that are linked to an access adp and am having a problem.
I can run the following code on access/access but when I try to run in on
access/ms-sql it errors out with "object variable or with block variable not
set". I assume that this is occurring because even after I set dbs =
currentdb, dbs still equals nothing but I don't know how to set it to
anything except the current database.
Thanks for any help,
Mike
Sub Test()
Dim dbs As Database
Dim qry As String
Dim rst As Recordset
Set dbs = CurrentDb
qry = "select fname from tblaccounts"
Set rst = dbs.OpenRecordset(qry, dbOpenDynaset)
While Not rst.EOF
Debug.Print rst!fname
rst.MoveNext
Wend
rst.Close
Set rst = Nothing
dbs.Close
Set dbs = Nothing
End Sub