473,433 Members | 2,026 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,433 software developers and data experts.

appending to text files

Is it possible to append records to a space delimited text file, using
Access 2000?
Nov 27 '05 #1
3 5053
TTBOMK TransferText will not append.

I have used this. It has NOT been extensively tested.

Public Sub AppendRecordsAsText( _
ByVal QueryString As String, _
ByVal FullFilePathandName As String)

Dim AppendString As String
Dim FileNumber As Integer

On Error GoTo AppendRecordsAsTextErr:

AppendString = CurrentProject.Connection.Execute(QueryString) _
.GetString(adClipString, , " ", vbNewLine)

FileNumber = FreeFile
Open FullFilePathandName For Append As #FileNumber

Write #FileNumber, , AppendString
Close #FileNumber

AppendRecordsAsTextExit:
'BE SURE low level file handles are released
Close
Exit Sub
AppendRecordsAsTextErr:
With Err
MsgBox .Description, vbCritical, "UH OH (Error #" & .Number &
")"
End With
Resume AppendRecordsAsTextExit:
End Sub

Sub test()
AppendRecordsAsText "SELECT * FROM Table1", "Table1.txt"
End Sub

Nov 27 '05 #2
rkc
Donald Grove wrote:
Is it possible to append records to a space delimited text file, using
Access 2000?


TransferText will overwrite existing files so one way you can do
what you want is to export to a different file and then append the
data to the existingfile by other means.
Here's an example of one way to go about that. You will want to
run tests and improve this. It's bare-bones stuff.

Function AppendFile(pathTo As String, pathFrom As String) As Boolean
Dim fHandle As Long
Dim appendData As String
AppendFile = True

On Error GoTo errHandler

appendData = GetFileContent(pathFrom)

fHandle = FreeFile
Debug.Print fHandle
Debug.Print appendData

Open pathTo For Append As #fHandle
Print #fHandle, appendData

exitHere:
Close fHandle
Exit Function

errHandler:
AppendFile = False
Resume exitHere
End Function

Function GetFileContent(path As String) As String
Dim s As String
Dim f1 As Long

f1 = FreeFile
Open path For Binary As #f1
s = String(LOF(f1), " ")
Get #f1, , s

Close #f1
GetFileContent = s

End Function
Nov 27 '05 #3
"Donald Grove" <do*********@verizon.net> wrote
Is it possible to append records to a space
delimited text file, using Access 2000?


Access has, since Version 1.0, had File I/O commands that can be used to
manipulate text files. One version of the Open statement is for files, WRITE
#, PRINT #, Put and Close are other commands (along with INPUT #, LineInput,
Get and Read). A tutorial on reading and writing Windows files is a bit much
for a newsgroup response. You might Google on the subject, check out the
Knowledge Base and other articles at http://support.microsoft.com and
http://msdn.microsoft.com.

If you have to do this without knowing some VBA code, you might consider
importing the file into a temporary Table, appending using an Append Query,
then exporting to a file.

Larry Linson
Microsoft Access MVP
Nov 28 '05 #4

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

Similar topics

1
by: Thomas Heller | last post by:
I want to append/insert additional data to an xml file. Context: I use gccxml to parse C header files. gccxml creates an xml file containing all the definitions from the header files. The xml...
5
by: rbt | last post by:
I know how to setup an empty list and loop thru something... appending to the list on each loop... how does this work with dicts? I'm looping thru a list of files and I want to put the file's...
1
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...
7
by: Don | last post by:
Hi all, With regards to the following, how do I append the datetimestamp to the filenames in the form? The files are processed using the PHP script that follows below. Thanks in advance,...
1
by: Jonathan Taylor | last post by:
I have a large XML file, that is too large to read in to XmlDocument. I need to append data to this XML file without creating a new file, since I don't want to have two copies of the large file...
16
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. ...
9
by: al jones | last post by:
Sorry, it's getting late and I'm tired. I'm trying to fill a richtect box with text derived from the array I was asking about earlier (thank you). I'm not sure what I'm seeing - since most of...
10
by: rory | last post by:
I can't seem to append a string to the end of a binary file. I'm using the following code: fstream outFile("test.exe", ios::in | ios::out | ios::binary | ios::ate | ios::app)...
4
by: John [H2O] | last post by:
I have a glob.glob search: searchstring = os.path.join('path'+'EN*') files = glob.glob(searchstring) for f in files: print f ___ This returns some files:
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
1
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,...
0
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.