473,507 Members | 2,477 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How can I remove hard returns (CR + LF) in a memo field string?

MLH
I use A97. I want to remove carriage return / linefeed pairs
from a memo field. How can I strip a string of these special,
non-printing characters?
Nov 13 '05 #1
2 5156
On Fri, 19 Aug 2005 14:43:01 -0400, MLH wrote:
I use A97. I want to remove carriage return / linefeed pairs
from a memo field. How can I strip a string of these special,
non-printing characters?


In Access 97 you'll need to write a User Defined function.

Copy and Paste the following into a Module

Change the Error Handling as needed.

Function StripReturns(StrIn As String) As String

On Error GoTo Err_Handler

Dim intX As Integer
Dim strName As String
Dim strNewName As String
Dim strY As String

strName = StrIn
For intX = 1 To Len(strName)
strY = Mid(strName, intX, 1)
If (Asc(strY) <> 13 And Asc(strY) <> 10) Then
strNewName = strNewName & strY
End If
Next intX
StripReturns = strNewName

Exit_StripReturns:
Exit Function

Err_Handler:
MsgBox "Error #: " & Err.Number & " " & Err.Description
Resume Exit_StripReturns
End Function
============

Call it from a query:
NewColumn:IIf(Not IsNull([FieldName]),StripReturns([FieldName]),"")

--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
Nov 13 '05 #2
MLH
Thx FredG
xxxxxxxxxxxxxxxxxxxx

On Fri, 19 Aug 2005 12:34:06 -0700, fredg <fg******@example.invalid>
wrote:
On Fri, 19 Aug 2005 14:43:01 -0400, MLH wrote:
I use A97. I want to remove carriage return / linefeed pairs
from a memo field. How can I strip a string of these special,
non-printing characters?


In Access 97 you'll need to write a User Defined function.

Copy and Paste the following into a Module

Change the Error Handling as needed.

Function StripReturns(StrIn As String) As String

On Error GoTo Err_Handler

Dim intX As Integer
Dim strName As String
Dim strNewName As String
Dim strY As String

strName = StrIn
For intX = 1 To Len(strName)
strY = Mid(strName, intX, 1)
If (Asc(strY) <> 13 And Asc(strY) <> 10) Then
strNewName = strNewName & strY
End If
Next intX
StripReturns = strNewName

Exit_StripReturns:
Exit Function

Err_Handler:
MsgBox "Error #: " & Err.Number & " " & Err.Description
Resume Exit_StripReturns
End Function
============

Call it from a query:
NewColumn:IIf(Not IsNull([FieldName]),StripReturns([FieldName]),"")


Nov 13 '05 #3

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

Similar topics

3
8635
by: Alfredo Agosti | last post by:
Hi folks, I have an Access 2000 db with a memo field. Into the memo field I put text with bold attributes, URL etc etc What I need to to is converting the rich text contained into the memo...
3
2013
by: Dave | last post by:
I need to strip out carriage returns from a memo field. Basically, one of the commercial databases we have uses a memo field for the address, and what I'd like to do is get rid of the carriage...
3
3014
by: John | last post by:
I have a field, data type Memo, in a job details table. I have a text box on a report which I need to print the contents of this field. My problem is that the text box will only display 255...
6
1672
by: MLH | last post by:
SELECT Adresses.RawData FROM Adresses WHERE (((Adresses.RawData)=InStr(1,,Chr$(13)))); Its not doing the trick for me and I'm not sure why.
10
4560
by: Lyle Fairfield | last post by:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbaac11/html/acfctNZ_HV05186465.asp "If the value of the variant argument is Null, the Nz function returns the number zero or a...
1
3007
by: alexsg | last post by:
A little while ago Ron P kindly responded to my inquiry on how to copy the first line of memo field into a text field, using a query: left(,instr(1,,vbCrLf)-1) This is great, but I would like...
3
9999
by: Gillian Steele | last post by:
I'm trying to import data into a memo field by running an append query. The data is to be imported as if it was entered with separate lines in the memo field. I have tried inserting chr(13)s...
9
5718
by: RMC | last post by:
Hello, I'm looking for a way to parse/format a memo field within a report. The Access 2000 database (application) has an equipment table that holds a memo field. Within the report, the memo...
11
3704
tdw
by: tdw | last post by:
Hi all, I have tried a few different methods to accomplish this, but with no luck. I will post the code for the latest attempt at the end of this post. I work at a land surveying company. This...
0
7114
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
7321
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
7377
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
7488
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
5623
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,...
1
5045
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...
0
3191
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
1544
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 ...
0
412
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...

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.