OutputTo PDF

WhiskyLima

Registered User.
Local time
Today, 23:03
Joined
Oct 8, 2013
Messages
48
Hey all, hopefully this should be an easy one for you. If have a report which I want to save as a PDF. The reports are named based on a couple of variables IE client name and invoice number; for example, 'whiskylima inv. 12345.pdf'

What I am trying to achieve is getting the save as location folder to pop up and ask where to save the file, with the filename already populated with the information.

Here is what I have

Code:
Private Sub cmdSavePDF_Click()
Dim LastName As String
Dim pdfName As String
Dim baseLocation As String

LastName = Mid([Forms]![SACreateInvoice]![txtClient], InStrRev([Forms]![SACreateInvoice]![txtClient], " ") + 1)
pdfName = LastName & " Inv " & Forms![SACreateInvoice]![txtInvoiceNumber] & ".pdf"

DoCmd.OutputTo acOutputReport, , "PDFFormat(*.pdf)", pdfName, False, "", , acExportQualityPrint

End Sub

I have tried this as an alternative but I get an error:

Microsoft Access cannot find the object '|1'.

Code:
DoCmd.OutputTo acOutputReport, pdfName, "PDFFormat(*.pdf)", pdfName, False, "", , acExportQualityPrint

I assume this is because I have told it what the file is called now but it dosn't know which report to save as that file. I would really like to be able to have my cake and eat it here if possible and I don't want to use a fixed save location or generic filename.

Cheers guys
 
Add a debug.print pdfName before your outputTo command and see what actual string you are passing to the command. I suspect the spaces and or other weird characters will be messing it up.

As a rule of thumb try and name saved files without spaces or , . ' / \ [ ] ( ) etc in them. It will cause you grief at the time of saving and even more if you try to then open the saved file from access.
 
Use a standard file/folder dialog to get the path, then pass it to the OutputTo function.
 
Ok how do I use the file/folder dialog?

Thanks for the help fellas
 

Users who are viewing this thread

Back
Top Bottom