Results 1 to 7 of 7
  1. #1
    Join Date
    Sep 2010
    Posts
    19

    Question Unanswered: type mismatch wiht recordset

    I am using ms access 2007 and i am getting this error when i run this code:

    code:
    Dim rst As Recordset
    Dim db As Database
    Dim temp As String
    Dim svrname As String

    Set db = CurrentDb
    Set rst = Recordset

    Set rst = db.OpenRecordset("tbl_AS_ReportClms", dbOpenDynaset)


    error:
    Runtime error 13
    type mismatch

  2. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Disambiguate your declarations:

    Dim rst As DAO.Recordset
    Dim db As DAO.Database

    and delete this line:

    Set rst = Recordset
    Paul

  3. #3
    Join Date
    Sep 2010
    Posts
    19
    I got it to work. this is the code i am using:

    Dim rst As Recordset
    Dim db As Database
    Dim svrname As String

    Set db = CurrentDb
    Set rst = Recordset

    Set rst = db.OpenRecordset("tbl_AS_ReportClms", dbOpenDynaset)


    I removed all but 3 references and I think that fixed it. I kept:
    Visual Basic for Applications
    Microsoft Access 12.0 Object Library
    Microsoft DAO 3.6 Object Library

  4. #4
    Join Date
    Mar 2009
    Posts
    5,441
    Provided Answers: 14
    It would have been better to fully qualify the objects, as Paul told you. Moreover the line: "Set rst = Recordset" is useless, at best.
    Have a nice day!

  5. #5
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    I would also recommend using ADO recordsets instead of DAO. Microsoft has preferred ADO for some time. It's possible that DAO may not be in a future release of Access.

  6. #6
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    I think MS tried to move away from DAO with 2000, but realized the error of their ways.

    From the Access team blog on 2007:

    In Office Access 2007, new objects, properties, and methods will be added to DAO to support the new features in the Access database engine. For example, multi-valued fields created using the new Lookup Wizard will be accessible from code as DAO recordsets.

    I don't think DAO is going anywhere in the near future. They wouldn't invest the time to add to it if they intended to drop it.
    Paul

  7. #7
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    I have been wondering how they were going to move away from DAO. I have a database that will move Access objects (Reports and Queries) between databases. And the only way I could fiogure out how to move them is using DAO. So at a minimum they would have to add that functionality to another technology (ADO or other).

    Thanks for the additional information. I still think, if you only learned one way to manipulate data in code, that ADO is a better choice. Although, once you understand how to use one technology it is easier to understand the other.

Posting Permissions

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