FileDialog Error

KerryDee

Registered User.
Local time
Today, 09:25
Joined
Nov 24, 2016
Messages
36
I am not sure why I am getting this error in red when I run the code. It is for a report to be saved in a folder. I am using Access 2016 (365). Here is the code below and thanks for your help!!!

Code:
Private Sub btnFolder_Click()

Dim strFolder As String
Dim strCaption As String
[COLOR="Red"][U]Dim fd As FileDialog
[/U][/COLOR]
Set fd = Application.FileDialog(msoFileDialogFolderPicker)

If fd.Show Then
    
    strFolder = fd.SelectedItems.Item(1)
    
    DoCmd.OpenReport "rptCarlsbad", acViewDesign, , , acHidden
    strCaption = Reports!rptCarlsbad.Caption
    DoCmd.Close acReport, "rptCarlsbad", acSaveNo

    DoCmd.OutputTo acOutputReport, "rptCarlsbad", acFormatPDF, strFolder & "\" & strCaption & ".pdf"

End If

Set fd = Nothing

End Sub
[Code]
 
Try:- Dim fd as Object

Sent from my SM-G925F using Tapatalk
 
You may need to set a reference, see below.

attachment.php
 

Attachments

  • ref.png
    ref.png
    75.3 KB · Views: 258
Thanks very much Uncle Gizmo and Access Blaster. I am not getting any type of errors implementing the changes you both suggested. However, I realized that all the reports I have on the DB is being saved, whereas I only needed one report that I am viewing to be saved to the folder. Do you have any suggestions on changing the code?

Thanks again.
 

Users who are viewing this thread

Back
Top Bottom