Bear with me folks- I am just an English teacher so a lot of this is beyond me. My code is creating a pdf file that includes everybody's reports instead of just that faculty member's reports.
Once I get it to generate the correct reports, I then have to figure out how to automatically email them.
Public Sub something3()
Dim db As Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT DISTINCT tblsection.Faculty, left(vtblfaculty.firstname,1)&vtblfaculty.lastname AS fn, vtblfaculty.email FROM vtblfaculty INNER JOIN tblsection ON tblsection.faculty=vtblfaculty.faculty WHERE term=" & Forms!frmimport!cbxTerm)
With rs
While Not rs.EOF
DoCmd.OpenReport "Backgrounds", acViewPreview, , , , "faculty =" & rs!Faculty
DoCmd.OutputTo acOutputReport, "Backgrounds", acFormatPDF, "C:\Users\Sonjurae\Desktop\" & rs!fn
rs.MoveNext
Wend
End With
One other thing is that I can't get the &".pdf" to work on the end of the filename, but that is no big deal right now.
Once I get it to generate the correct reports, I then have to figure out how to automatically email them.
Public Sub something3()
Dim db As Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT DISTINCT tblsection.Faculty, left(vtblfaculty.firstname,1)&vtblfaculty.lastname AS fn, vtblfaculty.email FROM vtblfaculty INNER JOIN tblsection ON tblsection.faculty=vtblfaculty.faculty WHERE term=" & Forms!frmimport!cbxTerm)
With rs
While Not rs.EOF
DoCmd.OpenReport "Backgrounds", acViewPreview, , , , "faculty =" & rs!Faculty
DoCmd.OutputTo acOutputReport, "Backgrounds", acFormatPDF, "C:\Users\Sonjurae\Desktop\" & rs!fn
rs.MoveNext
Wend
End With
One other thing is that I can't get the &".pdf" to work on the end of the filename, but that is no big deal right now.