Type Mismatch: Run Time Error 13!!

M

mj

Hi. I'm dumbfounded. I have the following code structure
that has always worked for me and all of a sudden it
doesn't. Any thoughts on this would be a tremendous help!
Thanks!

Here's my code:

Public Sub SendSalesPlans()

Dim recIMRSalesPlans As Recordset
Dim recIMRTerritories As Recordset
Dim objOutlook As New Outlook.Application
Dim objMessage As MailItem

Set db = CurrentDb

'It's getting hung up on the recordset tblTerritoriesIMR
which is just a three-column table with an autonumber and
two text fields.

Set recIMRTerritories = db.OpenRecordset("SELECT * " & _
"FROM [tblTerritoriesIMR]")

If Not recIMRTerritories.EOF Then
Do While Not recIMRTerritories.EOF

CreateSalesPlanLetter recIMRTerritories, recIMRSalesPlans

recIMRTerritories.MoveNext

Loop

End If

End Sub
 
A

Andrew Smith

You've probably got a reference to ADO - meaning that the recordset objects
are assumed to be ADO recordsets. If this is the problem there are three
possible solutions:

1. Remove the reference to ADO if you are not using ADO anywhere else.
2. Move the DAO reference to above ADO in the references list - but this
could cause problems if you have created any ADO recordsets elsewhere.
3. "Disambiguate" your Dim statements by putting;
Dim recIMRSalesPlans As DAO.Recordset

Number 3 is recommended as this will work whether or not you have a
reference to ADO, and is worth doing even if you remove the reference to
ADO. (This even reduces the amount of typing you have to do as you get an
IntelliSense list after you type DAO.)
 
R

Roger Carlson

Questions like this put me in mind of 3 possibilities:

1) The first is a References issue. Andrew covered that pretty well, but
you should also look for any MISSING references. They can also cause odd
error messages that don't have anything to do with the missing reference.

2) There might possibly bits of compiled code floating about (that's the
technical explanation <grin>) that were never removed during a recompile.
There is an undocumented feature called the Decompile that you can use to
remove all compiled code. When you recompile, all your code will be clean.
On my website (http://www.rogersaccesslibrary.com/knowledge.html) there is
an article called Decompiling Databases that explains the process.

3) The just might be corrupted data. There are several causes and fixes for
this. There is another article on my site by Jerry Whittle which covers
most of these:
http://www.rogersaccesslibrary.com/OtherLibraries.asp#Whittle,Jerry
 
M

mj

Andrew, you nailed it. THANKS!!! I removed the ADO
reference for now but will go with your suggestion in the
future...
-----Original Message-----
You've probably got a reference to ADO - meaning that the recordset objects
are assumed to be ADO recordsets. If this is the problem there are three
possible solutions:

1. Remove the reference to ADO if you are not using ADO anywhere else.
2. Move the DAO reference to above ADO in the references list - but this
could cause problems if you have created any ADO recordsets elsewhere.
3. "Disambiguate" your Dim statements by putting;
Dim recIMRSalesPlans As DAO.Recordset

Number 3 is recommended as this will work whether or not you have a
reference to ADO, and is worth doing even if you remove the reference to
ADO. (This even reduces the amount of typing you have to do as you get an
IntelliSense list after you type DAO.)

Hi. I'm dumbfounded. I have the following code structure
that has always worked for me and all of a sudden it
doesn't. Any thoughts on this would be a tremendous help!
Thanks!

Here's my code:

Public Sub SendSalesPlans()

Dim recIMRSalesPlans As Recordset
Dim recIMRTerritories As Recordset
Dim objOutlook As New Outlook.Application
Dim objMessage As MailItem

Set db = CurrentDb

'It's getting hung up on the recordset tblTerritoriesIMR
which is just a three-column table with an autonumber and
two text fields.

Set recIMRTerritories = db.OpenRecordset("SELECT * " & _
"FROM [tblTerritoriesIMR]")

If Not recIMRTerritories.EOF Then
Do While Not recIMRTerritories.EOF

CreateSalesPlanLetter recIMRTerritories, recIMRSalesPlans

recIMRTerritories.MoveNext

Loop

End If

End Sub


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top