I am trying to open a couple Ms Access recorsets in VB with the following code:
Dim POC As Database 'POC is short for Percent Off Clearance Database'
Dim rstSalesAndLWInventory As Recordset
Dim rstThisWeekInventory As Recordset
Dim rstPOCShtTable As Recordset
Set POC = CurrentDb
Set rstSalesAndLWInventory = POC.OpenRecordset("qrySlsSpringBlue04", dbOpenDynaset)
Set rstPOCShtTable = POC.OpenRecordset("tblSpringBlue04", dbOpenDynaset)
When I try to open these I get a tpe mismatch error. When i try to run the query in the access interface It works fine. I always was able to run queries
this way in access 97 VBA. I am now working in 2002 and the visual basic 6.3 editor comes up when I enter code.
You need to disambiguate the declarations, and you probably need to add the DAO reference in Tools/References. You want to check the “Microsoft DAO 3.6 Object Library”. Actually, make sure that’s done first, then change the code like:
Dim POC As DAO.Database 'POC is short for Percent Off Clearance Database'
Dim rstSalesAndLWInventory As DAO.Recordset