Enter "something" every 80 characters

D

denise

In a large memo type field, how can I enter something, like a carriage
return, after every 80th character?
Thanks for any help with this.
denise
 
P

Pete

I am a little puzzled as to why you would want to to do this as the text in
this field will wrap when bound to a form or a report addn you can use the
Can Grow formatting property on a report.

However, if you want a carriage return in a memo field you can use press
CTRL+ENTER. If you really do need to split the field programmatically then
let me know.
 
D

denise

I have an access database with several thousand records in a table. Each
record has a memo field with a report in it. The reports can be very long. I
need to break the reports up into 80 character pieces with something marking
each 80 characters. We have a vendor who is going to add these to their
product database for us and they have requested the data to be sent to them
this way. So I could use some help to set this up to run programmatically!
My programming skills are very rusty. Thanks a lot for your help.
 
J

John Spencer

Do you need to keep words in whole chunks or is it simply 80 characters and
you don't care if the break is in the middle of a word?

Short example using "This is a line with several words."

This is a line with sev
eral words.

Or does it need to be

This is a line with
several words.

Also, do you count the inserted character(s) when determining 80 characters.
Not that it will happen but what do you want done if you break on words and
there is no space to trigger the break (such as a long URL address)
 
J

John Vinson

In a large memo type field, how can I enter something, like a carriage
return, after every 80th character?
Thanks for any help with this.
denise

You'll need some VBA code to do this. Here's a function (untested, off
the top of my head); you can use it in a Select query as a calculated
field for export, or if you want to actually store the linebreaks, as
the Update To in an update query.

Public Function Linebreak80(ByVal strIn As String) As String
Dim iPos As Integer
Dim strOut As String
strOut = ""
Do Until Len(strIn) < 81
strOut = Left(strIn, 80) & vbCrLf
strIn = Mid(strIn, 81)
Loop
Linebreak80 = strOut
End Function

Note that this will break lines AT 80, which may well be in the middl
e of a word. Parsing to truly word-wrap will take more work!


John W. Vinson[MVP]
 
Top