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
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.
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.
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. -
-
Dim MyDB As DAO.Database
-
Dim rstEmployees As DAO.Recordset
-
Dim intFileNum As Integer
-
intFileNum = FreeFile()
-
Open "C:\Employee.txt" For Append As #intFileNum
-
Set MyDB = CurrentDb()
-
Set rstEmployees = MyDB.OpenRecordset("Employees", dbOpenForwardOnly)
-
With rstEmployees
-
Do While Not .EOF
-
Write #intFileNum, ![FirstName], ![LastName], ![Address]
-
.MoveNext
-
Loop
-
End With
-
Close #intFileNum
-
rstEmployees.Close
-
Set rstEmployees = Nothing
-
Sample data in Employee.txt - "Nancy","Davolio","507 - 20th Ave. E. Apt. 2A"
-
"Andrew","Fuller","1313 Mockingbird Lane"
-
"Janet","Leverling","722 Moss Bay Blvd."
-
"Margaret","Peacock","4110 Old Redmond Rd."
-
"Steven","Buchanan","14 Garrett Hill"
-
"Michael","Suyama","Coventry House Miner Rd."
-
"Robert","King","Edgeham Hollow Winchester Way"
-
"Laura","Callahan","4726 - 11th Ave. N.E."
-
"Anne","Dodsworth","7 Houndstooth Rd."
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.
ADezii 8,834
Recognized Expert Expert @NeoPa
Gotcha, no problemo!
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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...
|
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...
|
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...
|
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...
| |
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...
|
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...
|
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...
|
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...
|
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...
|
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...
| |
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...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |