附加带有标题记录的文本文件 [英] Appending Text file with a header record

查看:69
本文介绍了附加带有标题记录的文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在a2k中有一个数据应用程序,我需要创建两个固定宽度的

文本文件,然后将它们合并到一个文件中第一个文件是

标题信息第二个是交易数据。我已经尝试了

并试过但似乎无法正确使用,我正在使用查询

创建了我的导出文件,其规格工作正常,我得到了

难以将标题附加到我的事务文件中。到目前为止我的b $ b到底是什么样的..我在我的文件中找到的是,


1 2003100713250020441007

" ; c:\\ tTrans.Txt"


我需要知道的是如何声明c:\ trans.txt以便

追加数据而不是字符串


任何帮助都会很棒!


谢谢


Michael


+++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++


Private Sub Command0_Click()


Dim strFirstQuery As String

Dim strSecondQuery As String

Dim strPath As String

Dim strPath1 As String


strPath =" c:\Header .TXT" ''标题信息文件

strPath1 =" c:\ Trans.Txt" ''交易文件

strFirstQuery =" QryHeader"

strSecondQuery =" QryTransactions"


''输出交易标题

DoCmd.TransferText acExportFixed," EE2",strFirstQuery,strPath

''OutPut Transactions

DoCmd.TransferText acExportFixed," EE", strSecondQuery,strPath1


打开strPath以追加为#1

写#1,strPath1

关闭#1


结束子

I have a data application in a2k that I need to create two fixed width
text files and then combine them to a single file The first file is
header information and the second is transaction data. I have tried
and tried but just cant seem to get this right, I am using Queries to
created my export files with specifications which works fine, I get
stumped with the appending the header to my transaction file. What I
have so far looks like this .. What I wind up in my file is,

1 2003100713250020441007
"c:\Trans.Txt"

What I need to know is how to declare the c:\trans.txt so it will
append data and not the string

Any help would be great!

Thanks

Michael

+++++++++++++++++++++++++++++++++++++++++++++++++

Private Sub Command0_Click()

Dim strFirstQuery As String
Dim strSecondQuery As String
Dim strPath As String
Dim strPath1 As String

strPath = "c:\Header.txt" ''Header Information file
strPath1 = "c:\Trans.Txt" ''Transactions file
strFirstQuery = "QryHeader"
strSecondQuery = "QryTransactions"

''Output Transaction Header
DoCmd.TransferText acExportFixed, "EE2", strFirstQuery, strPath
''OutPut Transactions
DoCmd.TransferText acExportFixed, "EE", strSecondQuery, strPath1

Open strPath For Append As #1
Write #1, strPath1
Close #1

End sub

推荐答案

变量strPath1保存文件的名称和路径,而不是文件本身,所以

即附加内容。要附加文件中的数据,您需要打开文件并使用Get语句读取文件,然后附加该数据。您可以使用

a执行循环来运行读取/追加直到EOF。


在第二个TransferText调用中,如果使用acExportFixed,则会发生什么? />
acExportMerge,我没有看到每个常数所做的很好的解释。


-

Wayne Morgan

" Michael" <弥****** @ HotMail.Com>在消息中写道

news:43 ************************** @ posting.google.c om ...
The variable strPath1 is holding the name and path of the file, not the file itself, so
that is what is being appended. To append the data from the file, you will need to open
the file and use a Get statement to read the file and then append that data. You could use
a Do loop to run the read/append until EOF.

In the second TransferText call, what would happen if instead acExportFixed you used
acExportMerge, I don''t see a good explanation of what each of these constants do.

--
Wayne Morgan
"Michael" <Mi******@HotMail.Com> wrote in message
news:43**************************@posting.google.c om...
我在a2k中有一个数据应用程序,我需要创建两个固定宽度的文本文件然后将它们组合成一个文件第一个文件是
标题信息和第二个文件是交易数据。我已经尝试了尝试但是似乎无法做到这一点,我正在使用查询来创建我的导出文件,其规格工作正常,我感到难以接受标题到我的交易文件。到目前为止,我的内容看起来像这样......我在文件中发现的是,     " c:\ Trans.Txt"

我需要知道的是如何声明c:\ trans.txt以便它将
附加数据而不是字符串

任何帮助都会很棒!

谢谢

Michael

+++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++ +>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> br /> Dim strSecondQuery As String
Dim strPath As String
Dim strPath1 As String


strPath =" c:\Header.txt" ''标题信息文件
strPath1 =" c:\ Trans.Txt" ''交易文件
strFirstQuery =" QryHeader"
strSecondQuery =" QryTransactions"

''输出交易标题
DoCmd.TransferText acExportFixed," EE2" ,strFirstQuery,strPath
''OutPut Transactions
DoCmd.TransferText acExportFixed," EE",strSecondQuery,strPath1

打开strPath追加为#1
写# 1,strPath1
关闭#1

结束子
I have a data application in a2k that I need to create two fixed width
text files and then combine them to a single file The first file is
header information and the second is transaction data. I have tried
and tried but just cant seem to get this right, I am using Queries to
created my export files with specifications which works fine, I get
stumped with the appending the header to my transaction file. What I
have so far looks like this .. What I wind up in my file is,

1 2003100713250020441007
"c:\Trans.Txt"

What I need to know is how to declare the c:\trans.txt so it will
append data and not the string

Any help would be great!

Thanks

Michael

+++++++++++++++++++++++++++++++++++++++++++++++++

Private Sub Command0_Click()

Dim strFirstQuery As String
Dim strSecondQuery As String
Dim strPath As String
Dim strPath1 As String

strPath = "c:\Header.txt" ''Header Information file
strPath1 = "c:\Trans.Txt" ''Transactions file
strFirstQuery = "QryHeader"
strSecondQuery = "QryTransactions"

''Output Transaction Header
DoCmd.TransferText acExportFixed, "EE2", strFirstQuery, strPath
''OutPut Transactions
DoCmd.TransferText acExportFixed, "EE", strSecondQuery, strPath1

Open strPath For Append As #1
Write #1, strPath1
Close #1

End sub



Mi ****** @ HotMail.Com (迈克尔)在留言中写道:< 43 *************** ***********@posting.google。 com> ...
Mi******@HotMail.Com (Michael) wrote in message news:<43**************************@posting.google. com>...
我在a2k中有一个数据应用程序,我需要创建两个固定宽度的文本文件,然后将它们组合成一个文件第一个文件是
标题信息,第二个是交易数据。我已经尝试了尝试但是似乎无法做到这一点,我正在使用查询来创建我的导出文件,其规格工作正常,我感到难以接受标题到我的交易文件。到目前为止,我的内容看起来像这样......我在文件中发现的是,     " c:\ Trans.Txt"

我需要知道的是如何声明c:\ trans.txt以便它将
追加数据而不是字符串
I have a data application in a2k that I need to create two fixed width
text files and then combine them to a single file The first file is
header information and the second is transaction data. I have tried
and tried but just cant seem to get this right, I am using Queries to
created my export files with specifications which works fine, I get
stumped with the appending the header to my transaction file. What I
have so far looks like this .. What I wind up in my file is,

1 2003100713250020441007
"c:\Trans.Txt"

What I need to know is how to declare the c:\trans.txt so it will
append data and not the string




我认为问题是您可能需要先将两个查询输出到

文本。然后你可以打开一个用于追加而另一个用于读取。

读取第一行的每一行并将其写入第二行。那么你

应该是一个正在运行...我有点想知道你是否不能使用

SPACE(intSpaces)来创建你自己的分隔文本文件,因为那时你可以打开一个文本文件,循环浏览你的

查询记录集中的记录,将记录写入文件,关闭第一个

查询,打开第二个,重复输出的东西,然后追加

路径或者只是使用一个写语句......我想这只是
TransferText方法的
a限制 - 它假定每个对象有一个输出文件




I think the problem is that you may need to output the two queries to
text first. Then you can open one for append and the other for read.
Read each line of the first and write it to the second. then you
should be off an running... I''m kinda wondering if you can''t use
SPACE(intSpaces) to create your own delimited text file, because then
you can just open a text file, loop through the records in your
query''s recordset, write the records to the file, close the first
query, open the second, repeat the output stuff, and then append the
path or whatever just using a write statement... I think this is just
a limitation of the TransferText method - it assumes one output file
per object.


如果你的输出查询是一个怎么办?联合查询,将两个输出组合成一个

查询?


-

Wayne Morgan
What would happen if your output query was a Union query, combining both outputs into one
query?

--
Wayne Morgan


这篇关于附加带有标题记录的文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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