Need to change export VBA to let user select folder location (1 Viewer)

gojets1721

Registered User.
Local time
Today, 06:48
Joined
Jun 11, 2019
Messages
429
Okay that worked...last issue (I'm sorry). It doesn't seem to be applying the criteria. When I export, it's exporting every entry in the form to PDF when it should be exporting only one. Anything visible from the code that would cause the criteria to not be applied? Here's the code:

Code:
Private Sub btnExportEvent_Click()
    Dim reportName As String
    Dim criteria As String
    Dim fd As Object
    Dim filename As String
 
    reportName = "CompletedForm"
    criteria = "[ComplaintNumber]= " & [Forms]![frmDetails]![ComplaintNumber]

    Set fd = Application.FileDialog(2)
    filename = Me.CustomerLastName & ", " & Me.CustomerFirstName & " " & Format(Me.DateOpened, "m.d.yyyy") & ".pdf"
    With fd
        .InitialFileName = "C:\Users\Public\" & filename
        .Show
    End With
   
    MsgBox filename

    DoCmd.OpenReport reportName, acViewPreview, criteria, acHidden
    DoCmd.OutputTo acOutputReport, reportName, acFormatPDF, filename
    DoCmd.Close acReport, reportName, acSaveNo
End Sub
 

theDBguy

I’m here to help
Staff member
Local time
Today, 06:48
Joined
Oct 29, 2018
Messages
21,357
Okay that worked...last issue (I'm sorry). It doesn't seem to be applying the criteria. When I export, it's exporting every entry in the form to PDF when it should be exporting only one. Anything visible from the code that would cause the criteria to not be applied? Here's the code:

Code:
Private Sub btnExportEvent_Click()
    Dim reportName As String
    Dim criteria As String
    Dim fd As Object
    Dim filename As String

    reportName = "CompletedForm"
    criteria = "[ComplaintNumber]= " & [Forms]![frmDetails]![ComplaintNumber]

    Set fd = Application.FileDialog(2)
    filename = Me.CustomerLastName & ", " & Me.CustomerFirstName & " " & Format(Me.DateOpened, "m.d.yyyy") & ".pdf"
    With fd
        .InitialFileName = "C:\Users\Public\" & filename
        .Show
    End With
  
    MsgBox filename

    DoCmd.OpenReport reportName, acViewPreview, criteria, acHidden
    DoCmd.OutputTo acOutputReport, reportName, acFormatPDF, filename
    DoCmd.Close acReport, reportName, acSaveNo
End Sub
Hi. Glad to hear you're making good progress. What data type is "ComplaintNumber?"
 

Users who are viewing this thread

Top Bottom