Temporary report name for Email

G

Guest

One of the reports produced by my Access application is a sigle page which
displays information about individual customer orders. Each page is emailed
as a "snapshot" attachment. Is there a way to temporarily name the report to
reflect information in the report, e.g. Order Reference Number or Customer
Code, so that the report can be identified from the attachment name in the
email?

In addition, although this is not as important, how would you go about
creating a log of how many times a report was emailed and who the recipients
were?
 
A

Alt255

Hi Paulu, I generate thousands of individual PDF files for Emailing. I
put my code in the On Open event of the Access Report. I change the
Reports .Caption property to a name for example:


Me.Caption = "Established Cnslt Close Supervision REPORT RO " &
strROnum & " "

I also create a DAO recordset during the reports on open event adding
details to a log table. Here is the On Open event code in it's entirety

Private Sub Report_Open(Cancel As Integer)
Dim strROnum As String
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Select Case Len(Forms!frmadminform.txtRONUM) ' Pad any RO numbers with
Leading Zeros
Case 1
strROnum = "00" & Forms!frmadminform.txtRONUM
Case 2
strROnum = "0" & Forms!frmadminform.txtRONUM
Case 3
strROnum = Forms!frmadminform.txtRONUM
Case Else
MsgBox ("There is an Error in the Office ID. Check the
qrypstGetBm Query!")
rst.Close
dbs.Close
Exit Sub
End Select
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblpac_log")
Me.Caption = "Established Cnslt Close Supervision REPORT RO " &
strROnum & " " & Forms!frmadminform.txtBMNumber & " " &
Forms!frmadminform.txtBMName & " " &
Format(Forms!frmadminform.txtStartDate, "d-mmm-yyyy")
rst.AddNew
rst.Fields("file_name") = Me.Caption & ".pdf"
rst.Fields("ro_num") = Forms!frmadminform.txtRONUM
rst.Fields("bm_name") = Forms!frmadminform.txtBMName
rst.Fields("bm_number") = Forms!frmadminform.txtBMNumber
rst.Fields("date_created") = Now()
rst.Fields("pdf_produced") = True
rst.Fields("bm_language") = Forms!frmadminform.txtLanguage_cde
rst.Fields("area_name") = Forms!frmadminform.txtBMArea
rst.Fields("Report_Type") = "ESTBL"
rst.Update
rst.Close
DoCmd.Maximize
End Sub
 
G

Guest

This is just what I needed.

Thanks,
--
paulu


Alt255 said:
Hi Paulu, I generate thousands of individual PDF files for Emailing. I
put my code in the On Open event of the Access Report. I change the
Reports .Caption property to a name for example:


Me.Caption = "Established Cnslt Close Supervision REPORT RO " &
strROnum & " "

I also create a DAO recordset during the reports on open event adding
details to a log table. Here is the On Open event code in it's entirety

Private Sub Report_Open(Cancel As Integer)
Dim strROnum As String
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Select Case Len(Forms!frmadminform.txtRONUM) ' Pad any RO numbers with
Leading Zeros
Case 1
strROnum = "00" & Forms!frmadminform.txtRONUM
Case 2
strROnum = "0" & Forms!frmadminform.txtRONUM
Case 3
strROnum = Forms!frmadminform.txtRONUM
Case Else
MsgBox ("There is an Error in the Office ID. Check the
qrypstGetBm Query!")
rst.Close
dbs.Close
Exit Sub
End Select
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblpac_log")
Me.Caption = "Established Cnslt Close Supervision REPORT RO " &
strROnum & " " & Forms!frmadminform.txtBMNumber & " " &
Forms!frmadminform.txtBMName & " " &
Format(Forms!frmadminform.txtStartDate, "d-mmm-yyyy")
rst.AddNew
rst.Fields("file_name") = Me.Caption & ".pdf"
rst.Fields("ro_num") = Forms!frmadminform.txtRONUM
rst.Fields("bm_name") = Forms!frmadminform.txtBMName
rst.Fields("bm_number") = Forms!frmadminform.txtBMNumber
rst.Fields("date_created") = Now()
rst.Fields("pdf_produced") = True
rst.Fields("bm_language") = Forms!frmadminform.txtLanguage_cde
rst.Fields("area_name") = Forms!frmadminform.txtBMArea
rst.Fields("Report_Type") = "ESTBL"
rst.Update
rst.Close
DoCmd.Maximize
End Sub
 

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