Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

Run-time error '13': Type mismatch

Discussion in 'Information Technology' started by calmo, Jul 28, 2006.

  1. calmo

    calmo
    Expand Collapse
    Guest

    This one is driving me mad! The database I'm working with is meant to
    download data into Publisher to create posters, I have one version that
    works and one that gives me the Run-time error. The query works, the code
    looks right, and just to make life interesting, I created a new copy of the
    database importing all of the tables, queries, forms, posters and macros from
    the version that works, and I still get the same error message! I know this
    isn't much info, but if anyone else has come across anything similar, at
    least I won't feel like I'm going completely mad!!
     
  2. Loading...


  3. Dirk Goldgar

    Dirk Goldgar
    Expand Collapse
    Guest

    "calmo" <calmo@discussions.microsoft.com> wrote in message
    news:A03AE088-A32C-478F-9170-3362F883CF4A@microsoft.com
    > This one is driving me mad! The database I'm working with is meant to
    > download data into Publisher to create posters, I have one version
    > that works and one that gives me the Run-time error. The query
    > works, the code looks right, and just to make life interesting, I
    > created a new copy of the database importing all of the tables,
    > queries, forms, posters and macros from the version that works, and I
    > still get the same error message! I know this isn't much info, but
    > if anyone else has come across anything similar, at least I won't
    > feel like I'm going completely mad!!


    It would help a lot if you posted the line of code that is raising the
    error. I do have one guess: we often see questions about this error
    that are due to a confusion over the Recordset type. For example, in an
    Access 2000 or 2002 database, there will be code like this:

    Dim rs As Recordset

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

    and the error will be raised on the call to OpenRecordset. That's
    caused by A2K/A2K2 not having a default reference set to the DAO
    library, but instead having a reference to the ADODB library. Both of
    those libraries define a Recordset object, but they're not compatibile.
    So in the above code, the declaration is understood by VBA as making rs
    an ADODB.Recordset, but the OpenRecordset method returns a DAO
    recordset. So you get a type mismatch error.

    If this is your problem, you must first use the Tools -> References...
    dialog to add a reference to the Microsoft DAO 3.6 Object Library (if it
    isn't there already), and then *either* remove the reference to ActiveX
    Data Objects 2.x Library (if you don't plan to use ADO) *or* change your
    declaration of the recordset to:

    Dim rs As DAO.Recordset

    By explicitly identifying the library whose Recordset object you're
    declaring, you remove the confusion.

    There are other objects that are defined in both libraries and can cause
    confusion. The full list is:

    Connection
    Error
    Errors
    Field
    Fields
    Parameter
    Parameters
    Property
    Properties
    Recordset

    Note: the following objects exist with the same names in the ADOX and
    DAO models as well:

    Group
    Groups
    Index
    Indexes
    Property
    Properties
    User
    Users

    --
    Dirk Goldgar, MS Access MVP
    www.datagnostics.com

    (please reply to the newsgroup)
     
  4. Douglas J Steele

    Douglas J Steele
    Expand Collapse
    Guest

    Any possibility of Null values being assigned to non-variant variables?

    Any possibility of division by zero?

    --
    Doug Steele, Microsoft Access MVP
    http://I.Am/DougSteele
    (no e-mails, please!)


    "calmo" <calmo@discussions.microsoft.com> wrote in message
    news:A03AE088-A32C-478F-9170-3362F883CF4A@microsoft.com...
    > This one is driving me mad! The database I'm working with is meant to
    > download data into Publisher to create posters, I have one version that
    > works and one that gives me the Run-time error. The query works, the code
    > looks right, and just to make life interesting, I created a new copy of

    the
    > database importing all of the tables, queries, forms, posters and macros

    from
    > the version that works, and I still get the same error message! I know

    this
    > isn't much info, but if anyone else has come across anything similar, at
    > least I won't feel like I'm going completely mad!!
     
  5. calmo

    calmo
    Expand Collapse
    Guest

    Brilliant! Removing the ADO worked a treat. Thanks for your help.


    "Dirk Goldgar" wrote:

    > "calmo" <calmo@discussions.microsoft.com> wrote in message
    > news:A03AE088-A32C-478F-9170-3362F883CF4A@microsoft.com
    > > This one is driving me mad! The database I'm working with is meant to
    > > download data into Publisher to create posters, I have one version
    > > that works and one that gives me the Run-time error. The query
    > > works, the code looks right, and just to make life interesting, I
    > > created a new copy of the database importing all of the tables,
    > > queries, forms, posters and macros from the version that works, and I
    > > still get the same error message! I know this isn't much info, but
    > > if anyone else has come across anything similar, at least I won't
    > > feel like I'm going completely mad!!

    >
    > It would help a lot if you posted the line of code that is raising the
    > error. I do have one guess: we often see questions about this error
    > that are due to a confusion over the Recordset type. For example, in an
    > Access 2000 or 2002 database, there will be code like this:
    >
    > Dim rs As Recordset
    >
    > Set rs = CurrentDb.OpenRecordset(" ... ")
    >
    > and the error will be raised on the call to OpenRecordset. That's
    > caused by A2K/A2K2 not having a default reference set to the DAO
    > library, but instead having a reference to the ADODB library. Both of
    > those libraries define a Recordset object, but they're not compatibile.
    > So in the above code, the declaration is understood by VBA as making rs
    > an ADODB.Recordset, but the OpenRecordset method returns a DAO
    > recordset. So you get a type mismatch error.
    >
    > If this is your problem, you must first use the Tools -> References...
    > dialog to add a reference to the Microsoft DAO 3.6 Object Library (if it
    > isn't there already), and then *either* remove the reference to ActiveX
    > Data Objects 2.x Library (if you don't plan to use ADO) *or* change your
    > declaration of the recordset to:
    >
    > Dim rs As DAO.Recordset
    >
    > By explicitly identifying the library whose Recordset object you're
    > declaring, you remove the confusion.
    >
    > There are other objects that are defined in both libraries and can cause
    > confusion. The full list is:
    >
    > Connection
    > Error
    > Errors
    > Field
    > Fields
    > Parameter
    > Parameters
    > Property
    > Properties
    > Recordset
    >
    > Note: the following objects exist with the same names in the ADOX and
    > DAO models as well:
    >
    > Group
    > Groups
    > Index
    > Indexes
    > Property
    > Properties
    > User
    > Users
    >
    > --
    > Dirk Goldgar, MS Access MVP
    > www.datagnostics.com
    >
    > (please reply to the newsgroup)
    >
    >
    >
     

Share This Page