hi
trying to get an email in outlook with as many PDF attachments as there are records in the continuous subform -ie 1 attachment per subform record
in code below ( which is button on the subform ) 4 possible values for Me![Master] hence the if then statements - it should determine which report generates the PDF for the current record in subform
in my test record there are 2 entries in the continuous sub form
it's looping ok but result is the first record attached twice - what am i missing with the looping ?
my vb skills are fairly limited
hope i've explained it simply
thanks
trying to get an email in outlook with as many PDF attachments as there are records in the continuous subform -ie 1 attachment per subform record
in code below ( which is button on the subform ) 4 possible values for Me![Master] hence the if then statements - it should determine which report generates the PDF for the current record in subform
in my test record there are 2 entries in the continuous sub form
it's looping ok but result is the first record attached twice - what am i missing with the looping ?
my vb skills are fairly limited

thanks
Code:
Dim oApp As Object
Dim oEmail As Object
Dim FSO As New FileSystemObject
Dim folderPath As String
Dim fileName As String
'* begin - agp
Dim rs As DAO.Recordset
Set rs = Me.RecordsetClone
Set rs = rs.OpenRecordset
'* end - agp
Set oApp = CreateObject("Outlook.Application")
Set oEmail = oApp.CreateItem(0)
oEmail.To = ""
oEmail.Subject = "Please find attached your certificates"
oEmail.Body = "Hi your certificates are attached in PDF format"
With rs
If Not (.BOF And .EOF) Then .MoveFirst
While Not .EOF
If Me![Master] = "DOUBLE" Then
DoCmd.OutputTo acOutputReport, "rptdoublecert2", acFormatPDF, "c:\dbase\" & Me![CERT_NUM] & ".pdf", False
oEmail.Attachments.Add "c:\dbase\" & Me![CERT_NUM] & ".pdf"
Else
End If
If Me![Master] = "SINGLE" Then
DoCmd.OutputTo acOutputReport, "rptsingle2", acFormatPDF, "c:\dbase\" & Me![CERT_NUM] & ".pdf", False
oEmail.Attachments.Add "c:\dbase\" & Me![CERT_NUM] & ".pdf"
Else
End If
If Me![Master] = "BLANK" Then
DoCmd.OutputTo acOutputReport, "rptblank", acFormatPDF, "c:\dbase\" & Me![CERT_NUM] & ".pdf", False
oEmail.Attachments.Add "c:\dbase\" & Me![CERT_NUM] & ".pdf"
Else
End If
If Me![Master] = "TREBLE" Then
DoCmd.OutputTo acOutputReport, "rpttreble2", acFormatPDF, "c:\dbase\" & Me![CERT_NUM] & ".pdf", False
oEmail.Attachments.Add "c:\dbase\" & Me![CERT_NUM] & ".pdf"
Else
End If
.MoveNext
Wend
End With
Set rs = Nothing
oEmail.Display
Last edited: