thefourthwall
IS-IT--Management
I have code that exports a query to an Excel file.
The code I found in this forum while searching for something else, and it has worked well so far.
Manager wants me to export the query instead as a csv file, without headers.
The query is simple:
(Thanks Skip). The vba code that exports to xls is:
I experimented first with changing the extension but keeping the rest of the function, and that doesn't work. Tried DoCmd.TransferText also, but keep getting stuck. Help please.
The code I found in this forum while searching for something else, and it has worked well so far.
Manager wants me to export the query instead as a csv file, without headers.
The query is simple:
Code:
SELECT tblDevice.EID, tblDevice.Cell_Number
FROM tblDevice;
Where tblDevice.EID IS NOT NULL
Code:
Public Function EIDCell()
'Private Function cmdExport()
Dim strFilePath As String 'For the file path of your exported file - where you want to save it.
Dim strFileName As String 'For the actual file name of your exported workbook.
Dim strQuery As String 'Your Query Name
strFilePath = "G:\Share\IS\WSU\Administrative\Cell_Phone_Database\Exported\"
strFileName = "EIDs_and_CellNumbers" & ".xls"
strQuery = "qryEportEID_Phone_Number"
DoCmd.TransferSpreadsheet acExport, , strQuery, strFilePath & strFileName
End Function