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

Home Posts Topics Members FAQ

appending to text files

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

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

Public Sub AppendRecordsAs Text( _
ByVal QueryString As String, _
ByVal FullFilePathand Name As String)

Dim AppendString As String
Dim FileNumber As Integer

On Error GoTo AppendRecordsAs TextErr:

AppendString = CurrentProject. Connection.Exec ute(QueryString ) _
.GetString(adCl ipString, , " ", vbNewLine)

FileNumber = FreeFile
Open FullFilePathand Name For Append As #FileNumber

Write #FileNumber, , AppendString
Close #FileNumber

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

Sub test()
AppendRecordsAs Text "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(path To 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*********@ve rizon.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
3229
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 files may be somewhat largish, for 'windows.h' it has more than 5 MB. Since the xml does not contain #define statements, I want to run gccxml again...
5
1881
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 name and its sha hash into a dict on each loop. Many thanks, rbt
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...
7
19594
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, Don Following running on client-side:
1
2442
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 on the server. I've not seen any example that works so far, even with google. Can anyone help ?
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...
9
2954
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 the examples show how to load and save an rtf file into / from a rtbox (may want to save this guy, so that'll come in handy, later). Does anyone...
10
22629
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) outFile.write("teststring", 10); outFile.close(); If I leave out the ios::ate and ios::app modes my string is written to the start of the file as I'd expect but I...
4
1483
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:
0
7524
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
7451
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7960
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
5372
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5089
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
3501
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1944
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
1061
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
766
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.