Access MS Access Error 3061

Joined
Sep 15, 2009
Messages
1
Reaction score
0
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
 

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