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.
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: