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

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)

Thanks,
Marilyn
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
    Else
       Maildb.OPENMAIL
End If
 
strSql = "Select * from tbl_Old_Dates_email"
Set rstRecipient = DB.OpenRecordset(strSql, dbOpenDynaset)

Open in new window

Marilync1266Asked:
Who is Participating?
 
Jim Dettman (Microsoft MVP/ EE MVE)Connect With a Mentor President / OwnerCommented:
Marilyn,
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
JimD.
 

 
0
 
Rey Obrero (Capricorn1)Commented:
change this

Dim rstRecipient As Recordset

to

Dim rstRecipient As Dao.Recordset
0
 
Marilync1266Author Commented:
Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.