Remove Line Breaks.

R

Raphael

In a memo field I want to find and replace line breaks
with a space and double spaces with a single space. What
is the ascii equivalent or such for a "line break"? Or
how would I write a simple macro for this?

Thx!

Raphael
 
G

Guest

Raphael,

A Line break can either be a

Carriage Return which the ASCII for that is Chr(13)

Or

Carriage Return AND a Line Feed - chr(10)
so.. Chr(13) and then Chr(10)

in code you can also use vbCrLf

The code to replace them, would do something like this:
You can use the REPLACE function (look in help for
details) this function can be used to replace any
strings...

Memofield = Replace(" ",vbCrLf,1)

OR

Memofield = Replace(" ", chr(13),1)

OR

In general to see the ASCII code of any character in any
text field you can loop through character by character &
see...for example

L=len(MemoField) 'Get length of field, how many characters
For c=1 to L
Character=mid(MemeField,c,1)
mgsbox "Character - " & Character & " ASCII= " & _
Asc(Character)
next c

This should help,
Jeff
 
M

Marshall Barton

Raphael said:
In a memo field I want to find and replace line breaks
with a space and double spaces with a single space. What
is the ascii equivalent or such for a "line break"? Or
how would I write a simple macro for this?


You can use the Replace function to do these operations in a
text box expression:

=Replace(Replace(fieldname,Chr(13) & Chr(10)," ")," "," ")
 
G

Guest

That did it!

Private Sub extendeddesc_AfterUpdate()
extendeddesc = Replace(extendeddesc, Chr(13) & Chr
(10), " ")

End Sub

Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top