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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

export table from access to csv

Status
Not open for further replies.

JoanaSantos

Programmer
Feb 24, 2015
33
EU
Hi

i'm trying to export a table from access to a text file

i found this info:
expression .TransferText(TransferType, SpecificationName, TableName, FileName, HasFieldNames, HTMLTableName, CodePage)

can you explain me what i should put in: SpecificationName?
 
It's optional name of the file with export specification. If you need it, create the file manually first. In the text export wizard click "Advanced", set preferences and proceed with "Save as...".

combo
 
I doubt that this can be accessed via vba. Import/export specifications are stored in hidden system tables: MSysIMEXSpecs (specifications) and MSysIMEXColumns (specifications columns).

combo
 
BTW, just a bit curious, where is your .csv file going? Ie what other application will be using this data?
 
i just want to export the data of my table to a .csv file.. :) and save
 
[tt]DoCmd.TransferText transfertype:=acExportDelim, tablename:="TestTable", filename:="D:\TEST\Output.csv", HasFieldNames:=True[/tt]
If you need more control of the output format (delimiter, date format, decimal separator, text qualifier etc.) then, as I posted above, define manually specifications in your database and next use them in your code as SpecificationName argument.

combo
 
i used this code:
DoCmd.OutputTo acOutputQuery, "Interface_F01Incos0" & i & "_valor", acFormatTXT, strTxtPath, False


query-"Interface_F01Incos0" & i & "_valor"
strTxtPath = "G:\OrcControlo\SCC\Joana\INCOS0" & i & entidad & ".txt"


but each time a run the code i get this:

| Interface |
------------------------------------------------------------------------------------------------------
| PT;31/05/2015;05/06/2015;00411;NA001 |
------------------------------------------------------------------------------------------------------
| PT;31/05/2015;05/06/2015 |
------------------------------------------------------------------------------------------------------


like the table.. but i want to get just this:
PT;31/05/2015;05/06/2015;
PT;31/05/2015;05/06/2015
 
i tried your code but i couldn't change manually the specifications in my database
 
i can't do it anyway. Appears: "the text file specification does not exist
 
ok done. but now i have another problem

there is my code:



strTxtPath = "G:\Joana\INC01.txt"
Set ts = fso.CreateTextFile(strTxtPath, True)
ts.Close
DoCmd.TransferText acExportDelim, ("Inc01 Export Specification"), "Inc01_valor", strTxtPath, True

Set ts = Nothing



appears the runtime error 3027 - cannot update. dstabase or object is read-only
 
Access should create the output file itself, no need to use fso. Try to export to a r/w directory, there may be a problem with write permissions. You don't need parenthesis.

combo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top