473,549 Members | 2,579 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Appending data to .txt file from Query

3 New Member
Does anyone know how to append data from a MS Access query to a .txt file. I have a process to import data and check for errors. I would like to report the errors to a text file after every import without deleting the previous results (ie the Transfer text method)
Thanks
Oct 27 '06 #1
5 13589
NeoPa
32,564 Recognized Expert Moderator MVP
You would have to write code to process through the data (ADO or DAO RecordSet) and write to a text file opened using the Open Statement.
The help system will give you more details on those facilities.
Oct 27 '06 #2
NeoPa
32,564 Recognized Expert Moderator MVP
Of course, you could also write a new, and separate, file using TransferText, then use Shell to run a COPY command that appends the two files together into a resultant file. There are all sorts of possibilities there.
Jan 11 '09 #3
ADezii
8,834 Recognized Expert Expert
@ingrammx
Sometimes, I simply prefer a very Low Level approach such as the following code which will write the Values of 3 Fields in a Recordset to a Comma Delimited Text File. It this Format, it can then be easily Imported into a host of Database, and other varied, Applications.
Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim MyDB As DAO.Database
  3. Dim rstEmployees As DAO.Recordset
  4. Dim intFileNum As Integer
  5. intFileNum = FreeFile()
  6. Open "C:\Employee.txt" For Append As #intFileNum
  7. Set MyDB = CurrentDb()
  8. Set rstEmployees = MyDB.OpenRecordset("Employees", dbOpenForwardOnly)
  9. With rstEmployees
  10.   Do While Not .EOF
  11.     Write #intFileNum, ![FirstName], ![LastName], ![Address]
  12.       .MoveNext
  13.   Loop
  14. End With
  15. Close #intFileNum
  16. rstEmployees.Close
  17. Set rstEmployees = Nothing
  18.  
Sample data in Employee.txt
Expand|Select|Wrap|Line Numbers
  1. "Nancy","Davolio","507 - 20th Ave. E. Apt. 2A"
  2. "Andrew","Fuller","1313 Mockingbird Lane"
  3. "Janet","Leverling","722 Moss Bay Blvd."
  4. "Margaret","Peacock","4110 Old Redmond Rd."
  5. "Steven","Buchanan","14 Garrett Hill"
  6. "Michael","Suyama","Coventry House Miner Rd."
  7. "Robert","King","Edgeham Hollow Winchester Way"
  8. "Laura","Callahan","4726 - 11th Ave. N.E."
  9. "Anne","Dodsworth","7 Houndstooth Rd."
Jan 11 '09 #4
NeoPa
32,564 Recognized Expert Moderator MVP
Sorry ADezii. I resurrected this thread by accident yesterday when looking at my first screen of subscribed threads :D

I don't think the OP is likely to see this. It doesn't hurt to have answers visible for searchers though.
Jan 11 '09 #5
ADezii
8,834 Recognized Expert Expert
@NeoPa
Gotcha, no problemo!
Jan 12 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2104
by: dmiller23462 | last post by:
Hey guys.... I put an error-handling in my page and have it posted at the complete end of the code, see below(when people were putting in 's I was getting the delimiter errors). Great, I understand that now and it seems to be fixed but the data I'm pulling from the HTML fields is not being appended correctly do my Access DB....The field in...
16
12583
by: Michael | last post by:
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...
1
2208
by: Anna Warloe | last post by:
This might be a dumb question, but I am pretty new to Access.... I am trying to write code in Access to take river forecasts which are delivered as attachments in emails and append the data into an Access Database. Some forecasts are updated 4 times a day and others are only updated daily. I am trying to write a code which will only...
1
1795
by: Eli Sidwell | last post by:
I have an Access DB that contains 5 tables for the last 5 years. All 5 tables have the same structure. I wanted to keep each year separate for organizational purposes. But, I want to query all 5 tables with one query for an application. What would an query look like that uses all 5 tables as a source ? Should I create a view that...
1
1999
by: oasd | last post by:
I'm having difficulty appending data. I have an import macro (using the Transferspreadsheet function) to import data from an excel spreadsheet (located in a USB attached to the pc) to an access database. The data in the USB has addtional info to be added to the respective record in the database. The problem is that the data is not appended to...
4
2127
by: Bri | last post by:
Hi, First let me explain the process I have going on, then I'll address the problems I'm having: 1) Insert records in a temp table using a query 2) Using a query that joins the temp table with TableA Insert records into TableB 3) Delete records from temp Table 4) Table specs; temp Table - 4 fields, 3 indexes, gets 100-4500 records...
3
1902
by: MLH | last post by:
I have a query, qryAppend30DayOld260ies that attempts to append records to tblCorrespondence. When run, it can result in any of the following: appending no records, appending 1 record or appending many records. Two of the target fields in tblCorrespondence receiving values in the append operation are and . For any given VehicleJobID value, I...
4
6049
by: Jules48 | last post by:
I store comprehensive details of customers' "transactions" in Access (2000). At the moment, I (or my staff) duplicate entry of the information in an Excel spreadsheet which we use to extract stats and charts and to number crunch etc. Obviously, duplicating the data entry is onerous and open to error. What I'd like to do is enter the data...
3
1668
by: HSXWillH | last post by:
I've looked through the site and not found what I'm looking for here. I am not code-versed or anything like that so my skills are rudimentary at best. I'm using Access 03 on a Windows Vista environment. My question is about how to minimize data fields from large data-dumps in order to give myself the most recent recordset and to eliminate all...
0
7527
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7967
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7485
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7819
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6052
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5097
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3488
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1953
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1064
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.