导出为CSV delim(引用和concat问题) [英] Exporting to CSV delim (quote and concat issues)
问题描述
嘿大师,
我正在尝试将查询(QueryDataExport)导出到逗号分隔CSV文件。文件名应如下所示:C:\ DSF_20061127_124211.csv但是它导出为C:\ DSF_.csv。
此外,所有文本字段和标题都使用引号"导出。在他们周围,我不确定如何关闭它。我是否真的必须创建一个rst然后编码才能通过并手动删除它们或者是否有某种功能开关?
这就是我的意思已完成:
Private Sub cmdExport_Click()
出错时GoTo Err_cmdExport_Click
Dim MyDate
Dim MyFile
Dim Mystring
MyDate = Now()
Mystring =格式(MyDate," yyyymmdd_hhmmss")
MyFile =" C:\ Customer.com \ DSF_BWS_" &安培; My_String& " .csv"
DoCmd.TransferText acExportDelim ,, _
" QueryDataExport",MyFile,True
Exit_cmdExport_Click:
退出Sub
Err_cmdExport_Click:
MsgBox Err.Description
恢复Exit_cmdExport_Click
结束子
输出为:
" Center",Date ;,Dept,Sales,Count,Units,Di vision
1111,20061126,0, 2,0,0,10,0
1112,20061126,0,4,0, 0"," 10",0
但是我希望它看起来像这样:
中心,日期,部门,销售,计数,单位,分部
1111,20061126,0,2,0,0,10,0
1112,20061126,0,4,0,0 ,10,0
感谢您提供的任何帮助
干杯,
Cz。 :)
Hey Gurus,
I''m trying to export a query (QueryDataExport) to a comma delim CSV file. The file name should look like this "C:\DSF_20061127_124211.csv" however it is exporting as "C:\DSF_.csv".
Also all of the text fields and header are being exported with quotes "" around them and I''m unsure how to turn this off. Do I have to actually have to create a rst and then code it to go through and remove these manually or is there a function switch of some kind?
Here''s what I''ve done:
Private Sub cmdExport_Click()
On Error GoTo Err_cmdExport_Click
Dim MyDate
Dim MyFile
Dim Mystring
MyDate = Now()
Mystring = Format(MyDate, "yyyymmdd_hhmmss")
MyFile = "C:\Customer\DSF_BWS_" & My_String & ".csv"
DoCmd.TransferText acExportDelim, , _
"QueryDataExport", MyFile, True
Exit_cmdExport_Click:
Exit Sub
Err_cmdExport_Click:
MsgBox Err.Description
Resume Exit_cmdExport_Click
End Sub
Which outputs as:
"Centre","Date","Dept","Sales","Count","Units","Di vision"
"1111","20061126","0",2,"0","0","10",0
"1112","20061126","0",4,"0","0","10",0
However I''d like it to look like this:
Centre,Date,Dept,Sales,Count,Units,Division
1111,20061126,0,2,0,0,10,0
1112,20061126,0,4,0,0,10,0
Thanks for any help you can provide
Cheers,
Cz. :)
推荐答案
P.S。我正在尝试将数据导出到一个文件中,日期和时间作为文件名的一部分(不起作用)。
请帮助!
P.S. I''m trying to get it to export the data into a file with the date and time as part of the file name (which is not working).
Help please!
我见过你今天帮助了人们!关于这个命令我可以说什么 - 转移文本!它对我来说根本没有开始!
你很幸运能做到这一点!
所以我创建了自己的导出功能,我会给你:
Hi,
I''ve seen u helped people today! What i can say about this command - transfer text! it doesn''t started at all for me!
You''re lucky to do this!
So i''ve created my own export function that i''ll give you:
PEB,
这是一个好主意使用FreeFile()而不是硬编码1作为文件编号。
虽然功能很好。
CzarBJones(非常皇室),
您的格式字符串最好写成yyyymmdd_hhnnss,但您的格式仍应完美。
我不明白为什么它应解决为空白:S。
正如PEB所说,CSV格式非常难以控制。某些设置无法更改。
PEB,
It''s a good idea to use FreeFile() rather than to hard-code 1 as the file number.
Neat function though.
CzarBJones (very royal),
Your Format string would be better written as "yyyymmdd_hhnnss", but yours should still work perfectly.
I can''t see why it would resolve to blank :S.
As PEB says, CSV format is very uncontrollable. Certain settings cannot be changed.
这篇关于导出为CSV delim(引用和concat问题)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!