I can't figure out how to get my command button to send my report to the folder I want. Here is the code I originally used, and kept getting run time error 2501:
Dim MyPath As String
Dim MyName As String
MyPath = "\\Folder\Reports"
MyName = Me.txtDate.Value
DoCmd.OpenReport "Final Report", acViewPreview, , "[ID] = " & Me.[ID]
DoCmd.OutputTo acOutputReport, "Final Report", acFormatPDF, MyPath & MyName, True
DoCmd.Close acReport, "Final Report"
So, then I tried:
DoCmd.OpenReport "Final Report", acViewPreview, , "[ID] = " & Me.[ID]
DoCmd.OutputTo acOutputReport, "Final Report", acFormatPDF, "\\Folders\Reports" & Me.txtDate, True
DoCmd.Close acReport, "Final Report"
which also gave me a runtime error 2501.
I finally narrowed the issue down to exactly the folder/name, so I tried no name, and multiple different folders, and none of it would work. I tried it in macro instead of vba, and that still gave me a runtime error, just a different one..
So finally I ended up with this:
DoCmd.OpenReport "Final Report", acViewPreview, , "[ID] = " & Me.[ID]
DoCmd.OutputTo acOutputReport, "Final Report", acFormatPDF, "Final Report", True
DoCmd.Close acReport, "Final Report"
which is the only code so far to not give a runtime error, and to actually save it somewhere.... but, the problem is I don't get to pick where I save it, and they all come up with the same name so only one can save itself in that folder at a time..
Any help would greatly be appreciated.
Thank you in advance!
A Lyon