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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jim Dettman (Microsoft MVP/ EE MVE)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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Rey Obrero (Capricorn1)Commented:
change this

Dim rstRecipient As Recordset

to

Dim rstRecipient As Dao.Recordset
0
Marilync1266Author Commented:
Thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.