parameter query in code problems

P

Phil

I have been working on this code for a few days with a lot of help from here
and have now hit a brick wall, and cannot see where else to go

Again I apologise for it being a long post to give you all the info you will
need.


the code I have written is meant to get a concatenated list of email
addresses in a format that can be passed to outlook as a to:

I get a series of errors:

The specified field [EventID] could refer to mero than one table listed in
the from clause of your SQL statement.

Error 2147024894 - the system cannot find the specified file

Error 53: file not found

the code is:

Private Sub Command39_Click()

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

Set db = CurrentDb()
Set qdf = db.QueryDefs("Emailteacher")
sParam = Nz(Forms![Events1]![EventID], "")
qdf.Parameters![Em] = sParam

Set rst = qdf.OpenRecordset

With rst
If (Not .BOF) And (Not .EOF) Then
.MoveFirst
strEmail = Nz(.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"

End Sub

The SQL for the form is: SELECT Events.EventID, Events.EventName,
Events.Cohort, Events.StartDate
FROM Events
WHERE (((Events.StartDate)>Date()));

The SQL for the query is:

SELECT DISTINCT Teacher.Email, Sessions.EventID
FROM Sessions INNER JOIN Teacher ON Sessions.TeacherID = Teacher.TeacherID
WHERE (((Sessions.EventID)=[Em]));


thanks in advance for anyone who can help

Phil
 
P

Phil

Please ignore this post, I have found the problem, somehow I had changed the
query that was the source for the report being emailed, I feel like a prat

Phil
 

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