Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to set recordset object for dao

Status
Not open for further replies.

Rousseau10

Programmer
Feb 22, 2005
242
US
what am I doing wrong here. I made reference to Microsoft DAO.3.6 Object Library

Run time Error 91
"Object Variable or With Block Variable not set"
I get the erro on the Set rs .... line
What am I missing or doing wrong?

Dim DB As DAO.Database
Dim rs As DAO.Recordset

SQL = "SELECT * FROM GroupLookUp"
Set rs = DB.OpenRecordset(SQL)


thanks!
 
Do I need this line of code in an Access project. Is it not understood by default that I am referening to the current project Database??

Set DB = OpenDataBase(“C:\DBPath\DBFileName.MDB”)

 
You can refer to the current database in DAO with CurrentDB, there's no need for OpenDatabase, also check if you have a a reference to Microsoft DAO 3.# Object Library - in VBE - Tools | References... then

[tt]Dim DB As DAO.Database
Dim rs As DAO.Recordset

set db = currentdb

SQL = "SELECT * FROM GroupLookUp"
Set rs = DB.OpenRecordset(SQL)
' or without db object
' Set rs = currentdb.OpenRecordset(SQL)[/tt]

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top