473,396 Members | 1,990 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,396 software developers and data experts.

Remove Carriage Return in Access Exported Text File

Hi All -

I have some data that I export from Access to a pipe-delimited text
file. Unfortunately, the text file always has a carriage return symbol
at the end. I need to export this file frequently and send to a system
that cannot accept this character at the end of the file. I am looking
for a way, perhaps with VB code, to automate this process.

I found this code on another Google Group, but I can't get it to work.
Any advice appreciated. :O)

Here is that code:

Function RemoveCarriageReturn_UMG()
Set fso = CreateObject("Scripting.FileSystemObject")
Set NewFile = fso.CreateTextFile("C:\hello.txt")
Set file = fso.OpenTextFile("C:\return.txt")
Do While Not file.AtEndOfStream
CLine = file.ReadLine
CLine = Replace(CLine, vbCrLf, "")
NewFile.Write CLine
Loop

file.Close
NewFile.Close
Set NewFile = Nothing
Set file = Nothing
Set fso = Nothing
End Function

Jan 16 '07 #1
2 17998
You need to search for chr(10) and chr(13) and replace them

"Ellen" <el***********@gmail.comwrote in message
news:11**********************@m58g2000cwm.googlegr oups.com...
Hi All -

I have some data that I export from Access to a pipe-delimited text
file. Unfortunately, the text file always has a carriage return symbol
at the end. I need to export this file frequently and send to a system
that cannot accept this character at the end of the file. I am looking
for a way, perhaps with VB code, to automate this process.

I found this code on another Google Group, but I can't get it to work.
Any advice appreciated. :O)

Here is that code:

Function RemoveCarriageReturn_UMG()
Set fso = CreateObject("Scripting.FileSystemObject")
Set NewFile = fso.CreateTextFile("C:\hello.txt")
Set file = fso.OpenTextFile("C:\return.txt")
Do While Not file.AtEndOfStream
CLine = file.ReadLine
CLine = Replace(CLine, vbCrLf, "")
NewFile.Write CLine
Loop

file.Close
NewFile.Close
Set NewFile = Nothing
Set file = Nothing
Set fso = Nothing
End Function

Jan 16 '07 #2
Thanks Paradigm... I have just figured that out... (I'm not a
programmer, can you tell?)

Anyhow, I'm trying to use this in Access, but when I try to name it as
a Function it won't work...

Sorry to bother again... Any clue?
Dim fso, inputFile, outputFile
Dim str As String

fso = CreateObject("Scripting.FileSystemObject")

'1 means for reading

inputFile = fso.OpenTextFile("c:\return.txt", 1)

str = inputFile.ReadAll

'modify this string, replace required characters

str = Replace(str, "Char(10)", "")

'write back

outputFile = fso.CreateTextFile("c:\bleh.txt", True)

outputFile.Write (str)
Paradigm wrote:
You need to search for chr(10) and chr(13) and replace them

"Ellen" <el***********@gmail.comwrote in message
news:11**********************@m58g2000cwm.googlegr oups.com...
Hi All -

I have some data that I export from Access to a pipe-delimited text
file. Unfortunately, the text file always has a carriage return symbol
at the end. I need to export this file frequently and send to a system
that cannot accept this character at the end of the file. I am looking
for a way, perhaps with VB code, to automate this process.

I found this code on another Google Group, but I can't get it to work.
Any advice appreciated. :O)

Here is that code:

Function RemoveCarriageReturn_UMG()
Set fso = CreateObject("Scripting.FileSystemObject")
Set NewFile = fso.CreateTextFile("C:\hello.txt")
Set file = fso.OpenTextFile("C:\return.txt")
Do While Not file.AtEndOfStream
CLine = file.ReadLine
CLine = Replace(CLine, vbCrLf, "")
NewFile.Write CLine
Loop

file.Close
NewFile.Close
Set NewFile = Nothing
Set file = Nothing
Set fso = Nothing
End Function
Jan 16 '07 #3

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

Similar topics

4
by: Dr. Laurence Leff | last post by:
I am writing a Java program to read in XML file, modify some elements slightly, and then write it out. That XML file is prepared in Docbook. It works fine, except that it is disturbing the...
2
by: Paradigm | last post by:
I want to insert a carriage return into a text field. I am using insert into and \n for newline. The MYSQL database is accessed by a MS Access front end and the text field appears with a small...
7
by: Peter Tyler | last post by:
I have imported large text fields from Excel into Access 2000 which contain many repetitions of the Carriage Return character similar to "â–¡". How can I strip them out without doing it...
6
by: no_spam_for_gman | last post by:
Hi, I have been using the db2 export function for quite sometimes. Everytime I want to use it I have to remove every carriage return from my SQL statement and have it all on one line as shown in...
4
by: whitej77777 | last post by:
I am trying to write a user defined function that will allow me to strip off the last carriage return and line feed from a text field. We have address fields stored in a text field for our ERP...
2
by: Bobby | last post by:
Hi I'm trying to export some data from an Access table to Sage Line 50 using VBA. It works fine, except that very occasionally one of the fields contains a carriage return. If I step through my...
4
by: coolguyraj | last post by:
Hi. I have form that has a text box. I want insert unformatted text into the database. Even if the user gives an carriage return or New line feed in the database it should be stored as on single...
7
by: newbtemple | last post by:
Hey all. I'm having a bugger of a time trying to remove carriage returns. I have a large text file with a bunch of little squares. I'm guessing they're carriage returns from what i've googled. They...
11
by: evenlater | last post by:
My db allows the user to send email via CDO. The body of the email is determined in code. I have built an email form with To, CC and Subject lines and a large text box for the body of the message...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
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...
0
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
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...
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,...

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.