Q: How do I relate the desired filename to a field within the table of the datasource to "autoname" the file when saved.
In the below code the filename is NewReport. I want to change this to be the [Long Name] field of each record source when it saves. Reason being in the "autoname" function is because eventually I am going to create an archive button that will save a copy for each record to a monthly folder.
Let me know if there is any other information that will help find a solution. Thx
Sgt B
In the below code the filename is NewReport. I want to change this to be the [Long Name] field of each record source when it saves. Reason being in the "autoname" function is because eventually I am going to create an archive button that will save a copy for each record to a monthly folder.
Code:
Private Sub cmdSavePDF_Click() Dim strName As String Dim strFilter As String Dim strCurrentPath As String Dim strReportFile As String Dim strReport As String strFilter = "[SSN] = '" & Me.MemberSelect & "'" strName = Me.MemberSelect strCurrentPath = Application.CurrentProject.Path strReportFile = strCurrentPath & "\[B]NewReport[/B].pdf" strReport = "rptECR" Call DoCmd.OpenReport(ReportName:="rptECR", View:=Access.AcView.acViewReport, WhereCondition:=strFilter) Debug.Print "Report and path: " & strReportFile DoCmd.OutputTo objecttype:=acOutputReport, objectname:=strReport, outputformat:=acFormatPDF, outputfile:=strReportFile DoCmd.Close acReport, "rptECR" End Sub
Sgt B
Comment