Hi , I'm trying to send an individual email to small groups of people based on the results of a query. My problem appears because the query has a parameter which filters the results based on a Combo box in a form. The code I'm using returns the following "Error 3061 : Too few parameters.Expected 1" If I just run the query on its own it works perfectly. How can I create the filtered recordset without using a query in this way? The code I'm using is below and thanks in advance for any help.
Code:
Private Sub Command14_Click()
Dim MyDb As DAO.Database
Dim rsEmail As DAO.Recordset
Dim sToName As String
Dim sSubject As String
Dim sMessageBody As String
Set MyDb = CurrentDb()
Set rsEmail = MyDb.OpenRecordset("qryCourseDelegates", dbOpenSnapshot)
With rsEmail
.MoveFirst
Do Until rsEmail.EOF
If IsNull(.Fields(13)) = False Then
sToName = .Fields(20)
sSubject = "Confirmation #: " & .Fields(13)
sMessageBody = "Email Body Text " & vbCrLf & _
"Field A: " & .Fields(2) & vbCrLf & _
"Field B: " & .Fields(3) & vbCrLf & _
"Field C: " & .Fields(7)
DoCmd.SendObject acSendNoObject, , , _
sToName, , , sSubject, sMessageBody, False, False
End If
.MoveNext
Loop
End With
Set MyDb = Nothing
Set rsEmail = Nothing
End Sub