D
David Sullivan
HI I am using the following code , but when
it is run I am getting the following error
Runtime error 3061
Two few parameters , expected 3
am receiving the error from the following line of code
Set rs = db.OpenRecordset("qryEmail", dbOpenDynaset)
which is contained in the following procedure
Public Sub email()
Dim oApp As Outlook.Application
Dim objNewMail As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim db As Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("qryEmail", dbOpenDynaset)
Set oApp = New Outlook.Application
Set objNewMail = oApp.CreateItem(olMailItem)
With objNewMail
'Loop through recordset to add recipients
rs.MoveFirst
Do While Not rs.EOF
If Len(Trim(rs!email)) > 0 Then
Set objOutlookRecip = .Recipients.Add(rs!email)
objOutlookRecip.Type = olTo
End If
rs.MoveNext
Loop
.Subject = "Test subject"
.Body = "Your text message here."
.Save
.Send
End With
rs.Close
Set rs = Nothing
End Sub
this part of the code where it does not seem to be
passing the three parameters across to VBA. It should be
picking up the three parameters from the following query
SELECT Contacts.CompanyName, Contacts.Title, Contacts.EmailName,
Contacts.[Job Type]
FROM Job_Type INNER JOIN Contacts ON Job_Type.[Job Type] = Contacts.[Job
Type]
WHERE (((Contacts.Title) Is Null) AND ((Job_Type.[Job Type]) Is Null))
OR(((Contacts.Title) Like "*" & [Enter any character in the Job Title to
search by: ] & "*") AND ((Job_Type.[JobType]) Between
[Job_Type].[StartValue]
And [Job_Type].[EndValue]));
I hope someone can help as I am a complete Novice with
VB and am thinking I might be out of my depth here
it is run I am getting the following error
Runtime error 3061
Two few parameters , expected 3
am receiving the error from the following line of code
Set rs = db.OpenRecordset("qryEmail", dbOpenDynaset)
which is contained in the following procedure
Public Sub email()
Dim oApp As Outlook.Application
Dim objNewMail As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim db As Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("qryEmail", dbOpenDynaset)
Set oApp = New Outlook.Application
Set objNewMail = oApp.CreateItem(olMailItem)
With objNewMail
'Loop through recordset to add recipients
rs.MoveFirst
Do While Not rs.EOF
If Len(Trim(rs!email)) > 0 Then
Set objOutlookRecip = .Recipients.Add(rs!email)
objOutlookRecip.Type = olTo
End If
rs.MoveNext
Loop
.Subject = "Test subject"
.Body = "Your text message here."
.Save
.Send
End With
rs.Close
Set rs = Nothing
End Sub
this part of the code where it does not seem to be
passing the three parameters across to VBA. It should be
picking up the three parameters from the following query
SELECT Contacts.CompanyName, Contacts.Title, Contacts.EmailName,
Contacts.[Job Type]
FROM Job_Type INNER JOIN Contacts ON Job_Type.[Job Type] = Contacts.[Job
Type]
WHERE (((Contacts.Title) Is Null) AND ((Job_Type.[Job Type]) Is Null))
OR(((Contacts.Title) Like "*" & [Enter any character in the Job Title to
search by: ] & "*") AND ((Job_Type.[JobType]) Between
[Job_Type].[StartValue]
And [Job_Type].[EndValue]));
I hope someone can help as I am a complete Novice with
VB and am thinking I might be out of my depth here