sendobject and multiple emails parameter query

G

Guest

this is a follow up post. I am trying to use sendobject to send to multiple
email addresses. the sendobject is part of a module called emailasPDF, I was
advised to open recordset and loop through. I am sorry it is a long post but
thought I would give you all the info so you did not need to ask for anymore:


I passed the parameters because I originally had the error error message
"too few parameters: Expected 1"

this is the code I came up with:

Dim rst As DAO.Recordset
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strEmail As String

Set db = CurrentDb()
Set qdf = db.QueryDefs("Emailteacher")
qdf.Parameters!EventID = Forms![Events1]![EventID]
Set rst = qdf.OpenRecordset

With rst
If (Not .BOF) And (Not .EOF) Then
.MoveFirst
strEmail = .Fields("email")
.MoveNext
End If

If (Not .BOF) And (Not .EOF) Then
Do Until .EOF
strEmail = strEmail & ", " & .Fields("email")
.MoveNext
Loop
End If
.Close
End With

EMailAsPDF "Timetable", strEmail, Me.[EventName] & " " & "Cohort " &
Me.[Cohort] & " Timetable", "Enter Your Text Here"

the error occurs on line:

qdf.Parameters!EventID = Forms![Events1]![EventID]

with the error code 3265 item not found in this collection. here is the SQL
for the query it is based on:

SELECT Events.EventName, Sessions.StartTime, Sessions.StopTime,
Session.SessionDetails, Events.EventID, tblEventsLocation.Date,
Sessions.TeacherID, Events.Cohort, "Cohort - " & [Cohort] AS Chort1,
tblEventsLocation.Daynumber, "Day " & [Daynumber] AS [Day],
tblEventsLocation.DaytypeID, Sessions.SessionTypeID, Sessions.SessionID,
Sessions.SessionsID, Format([Sessions].[StartTime],"Short Time") & " - " &
Format([StopTime],"Short Time") AS [Time], tblEventsLocation.DaytypeID
FROM (Events INNER JOIN tblEventsLocation ON Events.EventID =
tblEventsLocation.[Event ID]) INNER JOIN (Sessions INNER JOIN [Session] ON
Sessions.SessionID = Session.SessionID) ON (tblEventsLocation.ID =
Sessions.TblEventsLocationID) AND (Events.EventID = Sessions.EventID)
WHERE (((Events.EventID)=[EventID]));
 
P

Perry

Answered in initial thread couple of msg before this one, same newsgroup
Krgrds,
Perry
 

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

Similar Threads


Top