473,396 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

export text to only one file.txt

I need create a macro for export to only one text file, of 3 TABLES

What is the necessary instructions (for create ONLY ONE FINAL text
file) ??

Thanks

Ramon
Oct 27 '06 #1
7 1679

Ramon Pam wrote:
I need create a macro for export to only one text file, of 3 TABLES

What is the necessary instructions (for create ONLY ONE FINAL text
file) ??

Thanks

Ramon
With a Macro? Not possible, AFAIK. With code, not too hard.
Look up Open, Write, Close, FreeFile in the help. There are examples.

Basic steps:
open the text file for input.
for each table/query
open a recordset based on the query/table
loop through the recordset, writing the fields to text. you could
create a tab-delimited file...
close recordset, go to the next
next table/query
close the textfile.

Oct 27 '06 #2
Sorry but i dont know programation languages

This instructions are for Access or for Visual Basic ???

In the MS Access Help file, not matches this instructions (Open,
Write, Close...)

Thanks for your cooperation

Ram
En/na pi********@hotmail.com say:
Ramon Pam wrote:
>I need create a macro for export to only one text file, of 3 TABLES

What is the necessary instructions (for create ONLY ONE FINAL text
file) ??

Thanks

Ramon

With a Macro? Not possible, AFAIK. With code, not too hard.
Look up Open, Write, Close, FreeFile in the help. There are examples.

Basic steps:
open the text file for input.
for each table/query
open a recordset based on the query/table
loop through the recordset, writing the fields to text. you could
create a tab-delimited file...
close recordset, go to the next
next table/query
close the textfile.
Oct 27 '06 #3
Yes. You can't do it with a macro. you could either output them all
to the same textfile using VB or you could output them all separately
with a macro and then use a DOS command to append them all to the same
file.

Here's my hacked together solution...

Option Compare Database
Option Explicit

Public Sub WriteToFile(ByVal strFile As String)
Dim intFileNo As Integer
Dim intCounter As Integer
Dim intFieldNo As Integer

Dim arrQueries(1 To 3) As String
Dim rs As DAO.Recordset
Dim strLine As String

'--SPECIFY THE QUERIES TO APPEND TO THE TEXT FILE
arrQueries(1) = "qryBrentwood"
arrQueries(2) = "qryDickson"
arrQueries(3) = "qryFranklin"

intFileNo = FreeFile
Open "C:\Cities.txt" For Output As #intFileNo
For intCounter = 1 To 3
Debug.Print
Print #intFileNo, vbCrLf
Debug.Print arrQueries(intCounter)
Print #intFileNo, arrQueries(intCounter)
Debug.Print "----------------------"
Print #intFileNo, "----------------------"

Set rs =
DBEngine(0)(0).QueryDefs(arrQueries(intCounter)).O penRecordset

Do Until rs.EOF
'--collect data from fields into a tab delimited string...
(GetString looks good here!!)
For intFieldNo = 0 To rs.Fields.Count - 1
If intFieldNo = 0 Then
strLine = rs.Fields(intFieldNo)
Else
strLine = strLine & vbTab & rs.Fields(intFieldNo)
End If
Next intFieldNo
'--Write result to file
Debug.Print strLine
Print #intFileNo, strLine
rs.MoveNext
Loop
rs.Close
Next intCounter

Set rs = Nothing
Close #intFileNo
End Sub

Oct 29 '06 #4
Ramon Pam <rp*****@gmail.comwrote in news:eh**********@news.ya.com:
I need create a macro for export to only one text file, of 3 TABLES

What is the necessary instructions (for create ONLY ONE FINAL text
file) ??

Thanks

Ramon
Perhaps you could use a Union Query on the three tables, then look at
TransferText in Help.

Cheers,
Alan Carpenter
Oct 29 '06 #5

Alan Carpenter wrote:
Ramon Pam <rp*****@gmail.comwrote in news:eh**********@news.ya.com:
I need create a macro for export to only one text file, of 3 TABLES

What is the necessary instructions (for create ONLY ONE FINAL text
file) ??

Thanks

Ramon

Perhaps you could use a Union Query on the three tables, then look at
TransferText in Help.

Cheers,
Alan Carpenter

Just as long as they're union-compatible sets...

Oct 30 '06 #6
Why not just export them to three text files and then issue a DOS command of
Copy txtFile1 + txtFile2 + txtFile3 txtFileFour.
TxtFileFour will then the have the contents of the first three files.
No programming or SQL involved.
"Ramon Pam" <rp*****@gmail.comwrote in message
news:eh**********@news.ya.com...
>I need create a macro for export to only one text file, of 3 TABLES

What is the necessary instructions (for create ONLY ONE FINAL text
file) ??

Thanks

Ramon


Oct 30 '06 #7


Thanks

Is easy and running

Many thanks
En/na Kc-Mass ha escrit:
Why not just export them to three text files and then issue a DOS command of
Copy txtFile1 + txtFile2 + txtFile3 txtFileFour.
TxtFileFour will then the have the contents of the first three files.
No programming or SQL involved.
"Ramon Pam" <rp*****@gmail.comwrote in message
news:eh**********@news.ya.com...
>I need create a macro for export to only one text file, of 3 TABLES

What is the necessary instructions (for create ONLY ONE FINAL text
file) ??

Thanks

Ramon


Oct 30 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Tim Eliot | last post by:
Just wondering if anyone has hit the following issue and how you might have sorted it out. I am using the command: DoCmd.TransferText acExportMerge, , stDataSource, stFileName, True after...
1
by: Bridget Willey | last post by:
I am using ACT 6 and am trying to "split" the database between records for customers and junk records. The accounts designated as "customers" have that word in the ID field, and I am using that...
3
by: Jorge Cecílio | last post by:
Hi! I would like to export some MS-Access reports output to pdf. However, the only possibility offered by Access (afaik) for me to export formatted output is snp (snapshot) (I use MS-Office...
13
by: Hemant Sipahimalani | last post by:
The following piece of code is being used to export HTML to excel. HttpContext.Current.Response.ContentType = "application/vnd.ms-excel"...
3
by: Daniel Wetzler | last post by:
Dear MSSQL- experts, I have a strange problem with SQLSERVER 2000. I tried to export a table of about 40000 lines into a text file using the Enterprise manager export assitant. I was astonished...
3
by: hbarnett | last post by:
I am in process of converting Access 97 databases to Access 2003. Some of the Access 97 databases export data to a text file with a non standard file extension, such as "ext" or "NAL". When I try...
1
by: smaczylo | last post by:
Hello, I've recently been asked to work with Microsoft Access, and while I feel quite comfortable with Excel, I'm at a complete loss with databases. If someone could help me with this issue I'm...
9
by: NEWSGROUPS | last post by:
I have data in a table in an Access 2000 database that needs to be exported to a formatted text file. For instance, the first field is an account number that is formatted in the table as text and...
3
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, I have a question for you. I have a .csv file which has many lines of data. Each line has many data fields which are delimited by ",". Now I need to extract part of data from this...
8
by: iheartvba | last post by:
Hi I am using Access 2007 and am trying to export a query to a fixed length text file. I tried using the following code to export the text file: DoCmd.TransferText acExportFixed, , "qryFFRDeFile",...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.