Export Table/query to specific location

jadown

Registered User.
Local time
Yesterday, 18:51
Joined
Dec 6, 2007
Messages
26
I am trying to export a query or table to a location that the user selects. So each time the export button is clicked the folder will change. But I want to be able to select the folder.

The code I have below is saving but not to the folder I want it to.

Code:
Private Sub CommandBtn_Click()
    Dim fileSelection As Object
    Dim strPath As String
    Set fileSelection = Application.FileDialog(4)
    With fileSelection
        .AllowMultiSelect = False
        If .Show = True Then
            strPath = .SelectedItems(1)
            ' use strPath with TransferSpreadsheet ...
            DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "TableName1", "Test.xlsx"
        Else
            MsgBox "no file selected"
        End If
    End With
End Sub
 
Last edited:
Never mind I see my mistake now. strPath & "\
 

Users who are viewing this thread

Back
Top Bottom