[Last Call] Learn how to a build a cloud-first strategyRegister Now


I'm receiving a Run Time Error 13 - Type Mismatch - using a recordset in VBA

Posted on 2008-11-18
Medium Priority
Last Modified: 2013-11-27
I've been running this code in another database with no problems.  I copied it to a new database and now I'm receiving Run Time Error 13 Type Mismatch at the line below.  Any ideas?

Set rstRecipient = DB.OpenRecordset(strSql, dbOpenDynaset)

Dim Maildb As Object        'The mail database
Dim UserName As String      'The current users notes name
Dim MailDbName As String    'THe current users notes mail database name
Dim MailDoc As Object       'The mail document itself
Dim AttachME As Object      'The attachment richtextfile object
Dim Session As Object       'The notes session
Dim EmbedObj As Object      'The embedded object (Attachment)
'Dim Subject As String
'Dim Attachment As String
'Dim Recipient As String
'Dim BodyText As String
Dim SaveIt As Boolean
Dim DB As DAO.Database
Dim strSql As String
Dim strRecipient As String
Dim recipient(5) As Variant
Dim rstRecipient As Recordset
Set DB = CurrentDb
'Start a session to notes
Set Session = CreateObject("Notes.NotesSession")
UserName = Session.UserName
'Attachment = strAttachment
'Recipient = strRecipient
'BodyText = strBodyText
'Subject = strSubject
SaveIt = "True"
'Next line only works with 5.x and above. Replace password with your password
'Session.Initialize ("biomerieux")
'Get the sessions username and then calculate the mail file name
'You may or may not need this as for MailDBname with some systems you
'can pass an empty string or using above password you can use other mailboxes.
MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf"
'Open the mail database in notes
Set Maildb = Session.GETDATABASE("", MailDbName)
If Maildb.ISOPEN = True Then 'Already open for mail
End If
strSql = "Select * from tbl_Old_Dates_email"
Set rstRecipient = DB.OpenRecordset(strSql, dbOpenDynaset)

Open in new window

Question by:Marilync1266
LVL 58

Accepted Solution

Jim Dettman (Microsoft MVP/ EE MVE) earned 2000 total points
ID: 22989059
For Access 2000 and up, the default data lib is ADO, which has a recordset object and is the reason for the error.  Open the VBA Editor, click tools/references.  Unselect the ADO data lib, then scroll down and find the "Microsoft Data Access Objects lib" and check it.
 This assumes your using no ADO.  If you are, then you need both libs checked and you need to explicitily delcare the objects.  ie.
Dim rstRecipient As DAO.Recordset

LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 22989079
change this

Dim rstRecipient As Recordset


Dim rstRecipient As Dao.Recordset

Author Closing Comment

ID: 31518030

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question