使用2种方法将表导出到TXT文件 [英] Export table to TXT file using 2 methods

查看:92
本文介绍了使用2种方法将表导出到TXT文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨guyz,只是尝试这个谷歌功能,所以如果我发布如果在

错误的区域我道歉。现在问我的问题。顺便说一句,我是新手来访问

编程,我已经做了一点vb6.0和vb.net但访问vba是一个

对我来说有点困惑我从来没有使用它加上我已经失去了

触摸vb编码自从最近8个monhts。


无论如何,我的问题是我想要出口一个'

我修改过的表,它是在提示符下从文件中获取的,现在我必须以相同的格式导出

相同的文件固定和分隔格式。我可以使用DoCmd.TransferText acExportDelim,ORDER

Export Specification,TBL0219,C:\ Test.txt轻松地完成此操作。 。我所做的只是改变

acExport为Fixed。


导入的文件具有固定宽度属性。它有2种类型的

记录M(主要记录集,即客户名称,电话,电子邮件等)和S(如果

运营商升级项目,它会添加这些记录w /对应字段)。

一旦修改它现在只有主要记录所有M'。现在导出

这种格式很简单,但是由于约束,我必须将新的

数据库输出设置为与之相同的格式,这意味着我有

现在检查哪个字段现在有额外的升级项目

即添加了QTY和PartNo。


关于我如何能有任何想法这个工作吗?


例子

1.原始输入文件看起来像


MTea 20050218 James Connor 1 1 1 3005 2003

4003等

MBag 20050219 Joanne Smith 1 1 1 3005 2003

4003等

S 1 3009


2.修改后看起来像


MTea 20050218 James Connor 1 1 1 3005 2003

4003等等

MBag 20050219 Joanne Smith 1 1 1 3005 2003

4003等1 3009



任何帮助都会得到帮助


感谢Neil

Hi guyz, just trying out this google feature so if i post if in the
wrong area i appologize. now to my question. BTW i''m new to access
programming, i''ve done a little vb6.0 and vb.net but access vba is a
little confusing for me since i have never used it plus i have lost
touch with vb coding since last 8 monhts.

anywayz, my problem is i''m trying to export a table that''s modified by
me which is taken from a file at a prompt, now i have to export the
same file in the same format it came in Fixed and Delimited formats. I
can do this easily using the DoCmd.TransferText acExportDelim, "ORDER
Export Specification", "TBL0219", "C:\Test.txt" . All i do is change
the acExport to Fixed.

The file being imported has fixed width properties. It has 2 types of
records M(main set of record i.e Cust name, ph, email etc) and S(if the
operator upsold items it adds these records w/ corresponding field).
Once it is modified it now has just main record all M''s. Now exporting
this format is easy but due to constraints i have to have the new
database output to the same format it used to be in which mean i have
to check now which one of the fields now has additional upsale items
i.e added QTY and PartNo.

Any ideas on how i can work this?

Example
1. Raw input file looks like

MTea 20050218 James Connor 1 1 1 3005 2003
4003 etc
MBag 20050219 Joanne Smith 1 1 1 3005 2003
4003 etc
S 1 3009

2. After my modification it looks like

MTea 20050218 James Connor 1 1 1 3005 2003
4003 etc
MBag 20050219 Joanne Smith 1 1 1 3005 2003
4003 etc 1 3009

3. Output needs to look like raw data again

Any help will be apprecaited

thanks Neil

推荐答案

Neil写道:
嗨guyz,只是尝试这个谷歌功能,所以如果我发布在
错误的区域,我道歉。现在问我的问题。 BTW我是新手来访问编程,我已经做了一点vb6.0和vb.net但是访问vba对我来说有点困惑,因为我从来没有使用它加上我有从最近8个monhts开始,用vb编码丢失了。

无论如何,我的问题是我正在尝试导出一个被我修改过的表格。从一个提示符下的文件,现在我必须以固定和分隔格式的相同格式导出相同的文件。我可以使用DoCmd.TransferText acExportDelim,ORDER
Export Specification,TBL0219,C:\ Test.txt轻松地做到这一点。 。我所做的就是将acExport更改为Fixed。

导入的文件具有固定的宽度属性。它有两种类型的记录M(主要记录集,即客户名称,电子邮件,电子邮件等)和S(如果
操作符升级项目,它会添加这些记录与相应字段)。
一旦修改它现在只有主要记录所有M'。现在导出
这种格式很简单但由于约束我必须将新的数据库输出设置为以前的格式,这意味着我现在要检查哪一个字段现在有额外的升级项目
即添加了QTY和PartNo。

关于我如何工作的任何想法?

示例
1.原始输入文件看起来像

MTea 20050218 James Connor 1 1 1 3005 2003
4003等
MBag 20050219 Joanne Smith 1 1 1 3005 2003
4003等
S 1 3009

2.修改后看起来很像

MTea 20050218 James Connor 1 1 1 3005 2003
4003等
MBag 20050219 Joanne Smith 1 1 1 3005 2003
4003等1 3009

3.输出需要再次看起来像原始数据
Hi guyz, just trying out this google feature so if i post if in the
wrong area i appologize. now to my question. BTW i''m new to access
programming, i''ve done a little vb6.0 and vb.net but access vba is a
little confusing for me since i have never used it plus i have lost
touch with vb coding since last 8 monhts.

anywayz, my problem is i''m trying to export a table that''s modified by
me which is taken from a file at a prompt, now i have to export the
same file in the same format it came in Fixed and Delimited formats. I
can do this easily using the DoCmd.TransferText acExportDelim, "ORDER
Export Specification", "TBL0219", "C:\Test.txt" . All i do is change
the acExport to Fixed.

The file being imported has fixed width properties. It has 2 types of
records M(main set of record i.e Cust name, ph, email etc) and S(if the
operator upsold items it adds these records w/ corresponding field).
Once it is modified it now has just main record all M''s. Now exporting
this format is easy but due to constraints i have to have the new
database output to the same format it used to be in which mean i have
to check now which one of the fields now has additional upsale items
i.e added QTY and PartNo.

Any ideas on how i can work this?

Example
1. Raw input file looks like

MTea 20050218 James Connor 1 1 1 3005 2003
4003 etc
MBag 20050219 Joanne Smith 1 1 1 3005 2003
4003 etc
S 1 3009

2. After my modification it looks like

MTea 20050218 James Connor 1 1 1 3005 2003
4003 etc
MBag 20050219 Joanne Smith 1 1 1 3005 2003
4003 etc 1 3009

3. Output needs to look like raw data again




为什么不要''你使用相同的导入/导出规范将

查询/表格数据导出到文本文件?


-

MGFoster ::: mgf00< at> ; earthlink< decimal-point> net

奥克兰,加利福尼亚州(美国)



Why don''t you use the same import/export specification to export the
query/table data to a text file?

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)


>为什么不使用相同的导入/导出规范将
> Why don''t you use the same import/export specification to export the
查询/表数据导出到文本文件中?

-
MGFoster :: :mgf00< at> earthlink< decimal-point> net
奥克兰,加利福尼亚州(美国)
query/table data to a text file?

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)




如果我的导入与

导出的规格相同会更容易。一旦我操作文件,看我何时导入它没有额外的字段添加

。这就是我要导入它的全部要点

我可以读取文件并按照我想要的方式进行操作。我不能提前添加那些

字段,因为不幸的是数据文件以这种方式出现和

我们以同样的方式导出的原因是因为它会去一个不同的地方

,它可以以相同的方式读取。该系统设置为

接受与我们的系统相同的方式。因此,除非我们更改所有昂贵或耗时的系统,否则我必须将其导入

它改变的方式保持该表并以其方式导出它来了

in。



Well it would be easier if my import were the same specification as
export. See when i import it does not have the extra fields that add
once i manipulate the file. That''s the whole point i''m importing it so
i can read the file and make it the way i want it. I cannot add those
fields in advance coz unfortunately the data file comes in such way and
the reason we export the same way is coz its gonna go to a diff place
where it may be read the same way or not. That system is setup to
accept the same way our systems are. So unless we change all the
systems which could be expensive or time consuming, i have to import it
the way it is change it keep that Table and export it the way it came
in.


这是我堂兄帮我的示例代码,有人可以帮我吗

填补其余部分!


函数TextExport_Fixed()

Dim rs作为DAO.Recordset

Dim strFix As String

Dim strSRecord As String

Dim strPad

设置rs = CurrentDb.OpenRecordset(tblname)


请勿rs.EOF

对于i = 0到rs.Fields.Count - 1

如果为左(rs.Fields(i).Name,3)= " QTY"然后


否则


结束如果

strPad = Space(rs.Fields(i).FieldSize - Len (rs(i)))

strFix = strFix& rs(i)& strPad

下一页


strFix = strFix& vbCrLf


rs.MoveNext

循环

rs.Close

调用WriteToFile

结束功能

This is a sample code my cousin helped me with, can someone help me
fill the rest!

Function TextExport_Fixed()
Dim rs As DAO.Recordset
Dim strFix As String
Dim strSRecord As String
Dim strPad
Set rs = CurrentDb.OpenRecordset(tblname)

Do While Not rs.EOF
For i = 0 To rs.Fields.Count - 1
If Left(rs.Fields(i).Name, 3) = "QTY" Then

Else

End If
strPad = Space(rs.Fields(i).FieldSize - Len(rs(i)))
strFix = strFix & rs(i) & strPad
Next

strFix = strFix & vbCrLf

rs.MoveNext
Loop
rs.Close
Call WriteToFile
End Function


这篇关于使用2种方法将表导出到TXT文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆