Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2005

    Unhappy Unanswered: Trouble opening recordsets

    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.

    Please Help

  2. #2
    Join Date
    May 2005
    Nevada, USA
    Provided Answers: 6
    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

  3. #3
    Join Date
    Feb 2005
    Another solution is using ADO recordsets like this:

    Dim rsWhatever as new adodb.recordset
    Dim strQuery as String

    strQuery = "Select * FROM tblWhatever;" strquery,application.currentproject.connection,adO penDynamic, adLockOptimistic

    And then use it as before.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts