Avatar of Mark01
Mark01
Flag for United States of America asked on

Access VBA - Remove Empty Lines

I am using the code shown below in the AfterUpdate event of a text box to remove empty lines, but all of the carriage returns are deleted. I want to eliminate the empty lines in a text box because I use paragraph styles in another app to control the space between paragraphs. Please help. Here are examples of what happens.

Code:
Author = Replace([Author], Chr(10), "")
Author = Replace([Author], Chr(13), "")

Original text:
line 1
line 2

After AfterUpdate event runs:
line 1line 2

Desired behavior:
line 1
line 2
test_050421.mdb
Microsoft AccessVBA

Avatar of undefined
Last Comment
Mark01

8/22/2022 - Mon
Jim Dettman (EE MVE)

Little confused on what you are looking to do.

Are your examples correct?

Jim.   
ASKER CERTIFIED SOLUTION
Bill Prew

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
als315

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Mark01

ASKER
@Jim: The Original text in the question is incorrect. It should be:
line 1

line 2

I have databases that contain a lot of text. As far as I know, Crystal Reports and Access reports do not have an equivalent to paragraph styles. MS Word and other apps use paragraph styles to control spacing.
Mark01

ASKER
The answers from Bill Prew and als315 solve the problem and remove the extra lines. Thank you, Bill, for the advice which is very helpful.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
SOLUTION
John Tsioumpris

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Mark01

ASKER
Thank you, als315 and Bill Prew.
Mark01

ASKER
Hi John, I received your code after I closed the question. Your code does work. Thank you for all of your help over the years.
Mark01

ASKER
Thanks, Jim, I just gave John credit for his answer.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
Fabrice Lambert

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Mark01

ASKER
Thank you, Fabrice Lambert, it works.