Recordset

  • Thread starter Thread starter Jeroen Verdrengh
  • Start date Start date
J

Jeroen Verdrengh

Hi,

I'm trying to open a recordset in vba, but it doesn't seem to work:

Stats_ConsultatiesBTWRapport_Totals is a query.

Dim rs As Recordset
Set rs = CurrentDb.OpenRecordset("Stats_ConsultatiesBTWRapport_Totals")

Although the other parameters are optional, an error occurs saying that 3
params are needed. When I try dbOpenDynaset as second parameter, another
error occurs saying the variable is not defined..

greets,

Jeroen
 
You don't say, but I'm guessing you're using Access 2000 or newer. Access
2000 and newer use ADO by default, you're attempting to use DAO. Both have
recordsets and that is what is causing the strange error message.

1) Set a reference to DAO. In the code editor (Alt+F11) go to
Tools|References. Place a check next to "Microsoft DAO 3.6 Object Library"
if there isn't one already there.

2) When you Dim DAO objects, specify the library to avoid confusion. Access
uses the references in the order that the checked ones are listed in the
References window, unless you tell it otherwise.

Dim rs As DAO.Recordset
 
Back
Top