Data Type Mismatch

B

Brian

Hello All,
I am trying to email a series of clients using the SendTo
routine. When I run this code I get a Data Type Mismatch
in the Set RS=dbs... line.
I'm stumped.

Dim dbs As Database, RS As Recordset
Dim lngRSCount As Long
Set dbs = CurrentDb

Set RS = dbs.OpenRecordset("emails", dbOpenDynaset)
lngRSCount = RS.RecordCount
If lngRSCount = 0 Then
MsgBox "No email messages to send.", vbInformation
Else
RS.MoveLast
RS.MoveFirst
Do Until RS.EOF

' Send the email
DoCmd.SendObject acSendReport, "emails",
acFormatTXT, email, , , "CAPTEL Survey", "Attached is the
CAPTEL Survey", 0

RS.MoveNext
Loop

End If
RS.Close
MyDB.Close
Set RS = Nothing
Set MyDB = Nothing
Close

Exit Sub

Thanks in advance.

Brian
 
R

RD Waibel

Hey...
Try defining the RS object like this:
Dim RS as DAO.Recordset

It fixed my issue.

Rob
 
G

Guest

Thanks a bunch Rob,
Works like a champ.
Unfortunately my code now just repeats the same record
over and over.
I've missed something else again.
 
D

Douglas J. Steele

You're not referring to any field from the recordset that I can see in the
statement:

DoCmd.SendObject acSendReport, "emails", acFormatTXT, email, , , "CAPTEL
Survey", "Attached is the CAPTEL Survey", 0

Somewhere in that statement, you'll need to refer to a field in the current
record of the recordset if you want anything to be different.
 

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