DoCmd.OutputTo - Formatting Title of Report
Posted on 2014-08-03
I am creating a DoCmd.OutputTo for an Access report in a PDF format. I am having trouble with the syntax for the title.
Here is the code I have:
Private Sub Print_Transfer_Report_Click()
Dim vFrom As String
Dim vTo As String
vFrom = Format([Forms]![FrmTransfRpt]![txtFrom], "mm/dd/yy")
vTo = Format([Forms]![FrmTransfRpt]![TxtTo], "mm/dd/yy")
DoCmd.OutputTo acReport, "rpt_TransferReport", "PDF Format(*.pdf)", _
"\\pmcfs\groups\HR\HR Extractions\TransferRpts\Employee Transfers From_" _
& vFrom & "_To_" & " " & ".PDF", False, 0
DoCmd.Close acReport, "rpt_TransferReport"
I want to add the input the From and To date from the form "FrmTransfrRpt". The fields are text boxes with a short date format, txtFrom and txtTo.
When I type in the code, the Access program overwrites the the txtTo field name with TxtTo.
I have tried to save the values to a temporary variable but that does not work either.
If I change the areas for the dates to a " ", the report runs.
Can someone help with the proper syntax?