Link to home
Start Free TrialLog in
Avatar of Fred Webb
Fred WebbFlag for United States of America

asked on

Apprnding a date to Access OutputTo statement

I have a form with a list box (lstReports) to select reports for various outputs email as PDF or Excel, print, View, and Save to PDF. All work fine except on the save to PDF, I want to append the current date to the end of the filename but it is failing with “the OutPutTo action was canceled” error.  If I exclude the append operation it save fine with the report name.
Private Sub btnSavePDF_Click()
On Error GoTo btnSavePDF_Click_Err
Dim stDocName2 As String

stDocName2 = Me.lstReports

    DoCmd.OutputTo acOutputReport, stDocName2, acFormatPDF, stDocName2 & Format(Date, mmddyyyy), True


btnSavePDF_Click_Exit:
    Exit Sub

btnSavePDF_Click_Err:
    MsgBox Error$
    Resume btnSavePDF_Click_Exit
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Patrick Matthews
Patrick Matthews
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Fred Webb

ASKER

Thanks Matt that worked I was so close. The only issue I now have is how do I select where to save it?