Access.Application.CurrentDb nothing?

I am at a loss to explain this:

I am getting the error:

Error "91" (object or block is not installed)

on the second line below:

Dim rs As DAO.Recordset

Set rs = CurrentDb.OpenRecordset("SELECT * FROM employees")

      

This also brings up the following:

`Set rs = CurrentDb.OpenRecordset("employees")`

      

Executing only ?CurrentDb.Name

in the immediate window also throws an error.

Now obviously the database is open as I am editing the form inside it, so what could be causing this error here?

0


source to share


4 answers


If you are working with an ADP project, you should use CurrentProject instead of CurrentDB.



+7


source


you should assign your .openRecordset method to the dao.recordset object or shared object ("late binding" method). try something like this:



dim rs as dao.recordset
set rs = currentDb.openRecordset(your SELECT instruction,...)

      

+3


source


Try to create a database object and use that instead of the CurrentDb reference. For example:

Dim db As DAO.Database
Dim rs As DAO.Recordset

Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT * FROM Employees")

      

+1


source


The reason I suspect the code won't work is because, according to M / Soft, the link text 'CurrentDb' is the method that will return "object variable of type Database ". Therefore the code shown by Forester93 should work. Its something that I will use and have been using for many years.

0


source







All Articles