Okay- so here is my code. What i would like to do is replace the DoCmd.OutputTo line with a DoCmd.SentTo line to email the reports to the appropriate faculty instead of just saving them in the folder.
I used this line but it did not work: DoCmd.SendObject (acSendReport, , acFormatPDF, "vtblfaculty.email&'@xxx.edu'","me@xxx.edu",,"test","this is a test",-1,,)
I have been working on this forever!
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
DoCmd.Close
rs.MoveNext
Wend
End With
End Sub
I used this line but it did not work: DoCmd.SendObject (acSendReport, , acFormatPDF, "vtblfaculty.email&'@xxx.edu'","me@xxx.edu",,"test","this is a test",-1,,)
I have been working on this forever!
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
DoCmd.Close
rs.MoveNext
Wend
End With
End Sub