Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Error 13: Type MisMatch

Error 13: Type MisMatch

Error 13: Type MisMatch

I'm trying to copy the Start Date from one form to the Start Date of each record on another form. In other words I want to change all of the Start Dates at once. Likewise for the /End Date.

I'm currently getting Error 13 Type Mismatch.

Here's code:

Dim rs As Recordset

Set rs = Forms!frmControlOutputs.Recordset


Do Until rs.EOF

Forms!frmControlOutputs.Form!txtStartDate = Me.txtNewStartDate.Value
Forms!frmControlOutputs.Form!txtEndDate = Me.txtNewEndDate.Value



Set rs = Nothing

As always, any help will be greatly appreciated.

Thanks, Kopy

RE: Error 13: Type MisMatch

I'm guessing either Me.txtNewStartDate.Value or Me.txtNewEndDate.Value is null. Try stepping through the code to see where the error comes up.

RE: Error 13: Type MisMatch

Dim rs As Recordset


Dim rs As Object

There Are 10 Types Of People In The world:
Those That Understand BINARY And Those That DonÆt.


RE: Error 13: Type MisMatch

Thanks. It did the trick.

RE: Error 13: Type MisMatch

> It did the trick

Which did? Stepping through the code, or declaring rs as Object?

If the former, where did the error arise?

RE: Error 13: Type MisMatch

Declaring as an Object resolved the issue.

RE: Error 13: Type MisMatch

No, it masked it. If that 'solved' the issue, then the error was occurring on the line:

Set rs = Forms!frmControlOutputs.Recordset

having declared

Dim rs as Recordset

But, if they are both recordsets, why a type mismatch (and why does dim rs as Object appear to fix things)?

The answer is that Access knows about 2 different recordset objects, one belonging to the ADO library, and one belonging to the DAO library, but bound controls only know about DAO recordsets (as DAO is the library considered native to Access)

When you declare

Dim rs as Recordset

then Access uses a default recordset object, and which one it uses depends on the order of the two libraries in question, DAO Object Library and the ActiveX Data Object library, in the references dialog in the VBA IDE. If the ADO version is listed first, then you get the ADO recordset object, and thus you get the type mismatch you are seeing. And why does declaring it as Object seem to fix the problem? Well, because variables declared as Object take on class interface of whatever they are subsequentally set to - but, along with losing Intellisense on the variable, this leads to potential problems now that the object variable can now represent any COM object whatsoever.

In my opinion you would be better off being explicit in your declaration:

dim rs as DAO.Recordset

(alternatively you can change the order libraries are listed in the References dialog to ensure the DAO library is listed first.)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close