Remove Extra Carriage Returns

T

Toxalot

The data I'm working with has memo fields with lots of trailing
carriage returns. I want to get rid of them. I'm using VBA. Is there a
RTrim type function that would get rid of carriage returns?

Jennifer
 
G

Guest

You need to use the Replace() function.

Replace(vbCrLf,"")

Look it up in the help for more options/information.

Steve
 
D

Douglas J. Steele

Of course, that will also remove any carriage returns inside the text.

Also, the syntax for the Replace function is Replace(TextToChange, vbCrLf,
"")
 
J

John W. Vinson

The data I'm working with has memo fields with lots of trailing
carriage returns. I want to get rid of them. I'm using VBA. Is there a
RTrim type function that would get rid of carriage returns?

Jennifer

It would be a bit tedious, but an Update query updating the field to

Left([fieldname], Len ([fieldname]) - 2)

with a query criterion on the field of

LIKE "*" & Chr(13) & Chr(10)

would trim off the last CrLf in the field. Running the query repeatedly
(perhaps from code) would nibble them all off eventually.

John W. Vinson [MVP]
 

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