Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Access 2003: Append table data to a text file with code - VBA

Posted on 2008-06-19
5
Medium Priority
?
1,059 Views
Last Modified: 2013-11-27
I need to append data from a table to a text file that has already been created with a DoCmd method.  Here is that
DoCmd.TransferText acExportFixed, "EXPORT_TABLE_Export_Specification", "EXPORT_TABLE", "C:IA_Subscriptions\Test.txt"

It works fine but now I want another line that appends data from another table to the text file.  Any help is greatly appreciated.

John
0
Comment
Question by:JohnMac328
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 65

Expert Comment

by:rockiroads
ID: 21823644
one of two ways perhaps?

1. Output to temp file, then append contents of temp file to main file

2. Open file, and write to it


one sec...
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 21823674
create a union query

select * from EXPORT_TABLE
union all
select * from OTHERTable

saved the union query then use in the


DoCmd.TransferText acExportFixed, "EXPORT_TABLE_Export_Specification", "UnionQueryName", "C:IA_Subscriptions\Test.txt"
0
 
LVL 65

Accepted Solution

by:
rockiroads earned 2000 total points
ID: 21823734
Method 1

Public Sub RunReport()

    Dim tempFile As Integer
    Dim mainFile As Integer
    Dim sLine As String
    Dim sTempFile As String
    Dim sMainFile As String
   
    sTempFile = "c:IA_Subscriptions\fred.txt"
    sMainFile = "C:IA_Subscriptions\Test.txt"
   
    DoCmd.TransferText acExportFixed, "EXPORT_TABLE_Export_Specification", "EXPORT_TABLE", sTempFile
   
    tempFile = FreeFile
    Open sTempFile For Input As #tempFile
   
    mainFile = FreeFile
    Open sMainFile For Append As #mainFile
   
    While Not EOF(tempFile)
        Line Input #tempFile, sLine
        Print #mainFile, sLine
    Wend
   
    Close #tempFile
    Close #mainFile
End Sub

0
 

Author Closing Comment

by:JohnMac328
ID: 31468856
Great, just what I needed.

Thanks
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 21823879
Cool :)
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Starting up a Project

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question