DoCmd.OutputTo help please.

Nosbod

New member
Local time
Today, 23:04
Joined
Sep 12, 2012
Messages
6
Hi,

I have created a simple database for generating quotes for our customers. I would like to have a button on a form that when clicked exports the current record to a .pdf. bringing up the "save as" dialog box with the filename to be taken from a textfield on the form called: QuoteNo. I do not want to automatically save the file to a location. So far i have the functionality but cannot get the save as box to have the correct filename (it defaults to the name of the report: Quote). I have spent some time browsing the forums and the only way i have seen it done is when the file is saved automatically in a specific path by using an [OutputFile] arguement, but i want to be able to choose where it's saved. My code thus far is below.
Thanks in advance,
Chris.

Private Sub butEXPPDF_Click()

Dim strDocName As String
Dim strWhere As String

strDocName = "Quote"
strWhere = "[Quote Number]=" & Me.QuoteNo

DoCmd.OpenReport strDocName, acPreview, , strWhere
DoCmd.OutputTo acOutputReport, , acFormatPDF, , True

End Sub
 
Welcome to the forum, this snip of code will allow you to pick a folder location to save the report, if you adjust the last part so it recognises you are wanting to name it as well then you should have a solution..

Sub showme1()
Dim fd As FileDialog
Dim strFolder As String

Set fd = Application.FileDialog(msoFileDialogFolderPicker)

If fd.Show = -1 Then
strFolder = fd.SelectedItems.Item(1)
Else
Exit Sub
End If

DoCmd.OutputTo acOutputReport, "rptReservations", acFormatPDF, strFolder & "\rptTrackingReport.PDF"
Set fd = Nothing

End Sub
 
Hi Trevor,

Apologies for the very long delayed response - I finally got this to work with your help.

Chris.
 
The important thing is that you have a solution.

But thanks for letting me know Chris.
 

Users who are viewing this thread

Back
Top Bottom