The following module, which works just fine, is designed to mass
e-mail info to individual projects but the attachment is always
"rptexpendituredetail.xls".
Is there any way to change the attachment's filename each during each
loop so each project can receive a uniquely named file??
FYI, rptexpendituredetail is the name of the Access report that
filters the data for each project based on a query.
===============================================
Private Sub cmdMassEmail_Click()
Dim stDocName As String
Dim ProjManager As String
Dim ProjName As String
Dim rst As Recordset
stDocName = "rptexpendituredetail"
For i = 0 To ProjNumber.ListCount - 1
ProjectNumber = ProjNumber.ItemData(i)
Set rst = New Recordset
rst.Open "select projectmanager, projectname from [1641
Projects] where ProjectNumber = " & ProjectNumber,
CurrentProject.Connection, adOpenKeyset, adLockOptimistic
If Not IsNull(rst("ProjectManager")) Then
ProjManager = rst("ProjectManager")
ProjName = rst("ProjectName")
DoCmd.SendObject acReport, stDocName, acFormatXLS,
ProjManager, , , SubjectLine & " - " & ProjName & " (" & ProjectNumber
& ")", "Attached is your EDR for project number " & ProjectNumber,
False
End If
rst.Close
Next i
End Sub
========================