473,785 Members | 2,807 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 RemoveCarriageR eturn_UMG()
Set fso = CreateObject("S cripting.FileSy stemObject")
Set NewFile = fso.CreateTextF ile("C:\hello.t xt")
Set file = fso.OpenTextFil e("C:\return.tx t")
Do While Not file.AtEndOfStr eam
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 18031
You need to search for chr(10) and chr(13) and replace them

"Ellen" <el***********@ gmail.comwrote in message
news:11******** **************@ m58g2000cwm.goo glegroups.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 RemoveCarriageR eturn_UMG()
Set fso = CreateObject("S cripting.FileSy stemObject")
Set NewFile = fso.CreateTextF ile("C:\hello.t xt")
Set file = fso.OpenTextFil e("C:\return.tx t")
Do While Not file.AtEndOfStr eam
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("S cripting.FileSy stemObject")

'1 means for reading

inputFile = fso.OpenTextFil e("c:\return.tx t", 1)

str = inputFile.ReadA ll

'modify this string, replace required characters

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

'write back

outputFile = fso.CreateTextF ile("c:\bleh.tx t", True)

outputFile.Writ e (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.goo glegroups.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 RemoveCarriageR eturn_UMG()
Set fso = CreateObject("S cripting.FileSy stemObject")
Set NewFile = fso.CreateTextF ile("C:\hello.t xt")
Set file = fso.OpenTextFil e("C:\return.tx t")
Do While Not file.AtEndOfStr eam
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
9884
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 carriage returns in places where they have meaning. Attached are a sample input file, the sample output file, and a simplified version of my Java program. My real file, examines certain element's attributes and adds certain elements to the DOM...
2
7565
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 square where the new line should be. It appears that the \n is interpreted in Access differently. Is there a way of putting a carriage return into the field so that it is seen as such by Accesss? Alex
7
8491
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 manually? The Find and Replace function does not work as it does not recognize this character. Thanks in advance for any advice. Peter Tyler
6
8751
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 the following simplistic example: db2 export to myfile.txt of del select a,b,c from staff This can be time consuming when you have big SQL joining many tables
4
27832
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 system and some of them have an extra carriage return and line feed at the end of them. This causes havoc when we sync between our ERP system and CRM system. If anyone knows a way to solve this problem the help would be appreciated. Examples:...
2
2913
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 code in debug, it handles the carriage return by replacing it with a square in the middle of the text. I need a way in Access of identifying the carriage return and replacing it with a space. Is there a function I could use to do this?
4
4701
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 line without any formatting. I just want to remove New Line Feed(\n) Carriage Return(\r) spaces at the begin and end of the string.
7
22988
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 are not standard ascii characters. Anywho, i'de like to get rid of them. I've got a loop that tests this condition: If textCharArray((charPosition) + (133 * rowPosition)) = Environment.NewLine Then textCharArray((charPosition) + (133 *...
11
12602
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 so the user can edit the default email message body before sending the message. But when I populate the large text box (txtBody), I can't get it to include the carriage returns. I've tried vbNewLine, vbCrLf, Chr(10) and Chr(13). I've got the...
0
10336
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10155
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10095
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9953
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8978
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6741
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5383
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4054
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
3
2881
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.