Kiekeboe
asked on
VBA Export Table to CSV file
Hi
I want to make a "export"button on a form to transform a table into a .csv file.
Can somebody help me with the right VBA code?
I've tried things like:
DoCmd.TransferSpreadsheet acExport, "RESULTS", "C:\Temp\Results.csv"
Hopefully somebody can help me
J
I want to make a "export"button on a form to transform a table into a .csv file.
Can somebody help me with the right VBA code?
I've tried things like:
DoCmd.TransferSpreadsheet acExport, "RESULTS", "C:\Temp\Results.csv"
Hopefully somebody can help me
J
Hi
You are trying to create a csv file so I would use
DoCmd.TransferText acExportDelim, "specificationname", "tablename", "file name", False, "headersrequired"
Use the specifation name to create the template for the ouput eg date formats, quotes to wrap around text etc
You can as easily create the out froma macro where the action is "TransferText" and then fill in the boxes below.
Rohit
You are trying to create a csv file so I would use
DoCmd.TransferText acExportDelim, "specificationname", "tablename", "file name", False, "headersrequired"
Use the specifation name to create the template for the ouput eg date formats, quotes to wrap around text etc
You can as easily create the out froma macro where the action is "TransferText" and then fill in the boxes below.
Rohit
or
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "RESULTS", "C:\Temp\Results.csv", True
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "RESULTS", "C:\Temp\Results.csv", True
Hi, take a look at the help file for the 'OutputTo' Method
DoCmd.OutputTo ...
You may have to run the install for access in order to add filters for CSV file format support.
Good Luck
Toby
DoCmd.OutputTo ...
You may have to run the install for access in order to add filters for CSV file format support.
Good Luck
Toby
Kiekeboe,
ignore my post, did not see that it is a csv file. my post is only good for .xls files
ignore my post, did not see that it is a csv file. my post is only good for .xls files
ASKER
Thanks for your reactions. The export to an Excel file works fine, but csv not yet.
Any tips?
Any tips?
HI did you try the the transfertext command i suggested. That should produce the csv file you require. Don't forget to set the export specification. This is easily done when you do a export file and then click on the advanced button check the setting and the save the specification.
Rohit
Rohit
ASKER
@Rohot
I've tried it, but i don't understand what to do with "specificationname" and "headersrequired".
DoCmd.TransferText acExportDelim, "specificationname", "RESULTS", "C:\TEMP\results.csv", False, "headersrequired"
I've tried it, but i don't understand what to do with "specificationname" and "headersrequired".
DoCmd.TransferText acExportDelim, "specificationname", "RESULTS", "C:\TEMP\results.csv", False, "headersrequired"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Rohit, that's it!
'-------------------------
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "RESULTS", "C:\Temp\Results.csv"