Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Export query as .csv file 1

Status
Not open for further replies.

thefourthwall

IS-IT--Management
Feb 26, 2002
387
US
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:
Code:
SELECT tblDevice.EID, tblDevice.Cell_Number
FROM tblDevice;
Where tblDevice.EID IS NOT NULL
(Thanks Skip). The vba code that exports to xls is:
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
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.
 
Something like
Code:
strFilePath = "G:\Share\IS\WSU\Administrative\Cell_Phone_Database\Exported\"
strFileName = "EIDs_and_CellNumbers" & ".CSV"
strQuery = "qryEportEID_Phone_Number"

DoCmd.TransferText acExportDelim, , strQuery, strFilePath & strFileName, False
 
Golom: Thank you! I was stuck and appreciate your help - you're a lifesaver!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top