Access Reports - Word Wrapping in a Text Box

  • Thread starter Thread starter mattieflo
  • Start date Start date
M

mattieflo

One of the requirements for one of our projects is for a text box in a
report, if they have something in the field like 'RFE_TRR_SEX' and it has to
wrap in the text box, that it wraps right after an underscore. Anyone have
any idea where to start on this one?
 
an idea of where to start, sure:

You'll need to know how many characters will fit in a line
then you'l use an Instr() to find the last underscore before that number
then you use a left() to get a string upto that underscore
add a vbcrlf (hard return) and add the rest of the string with a Right()

its a little more complex if you have >2 lines
 
If you want 'RFE_TRR_SEX' to appear as

RFE
TRR
SEX

then the split function should help you do that. Define an array (it may
have to be type VAriant, not positive about that), then do something like:

myArray = Split(myFIeld, "_")
txtField = vbnullstring
for i = 0 to ubound(myArray) - 1
if i > 0 then
txtField = txtField & vbcrlf
end if
txtField = txtField & myArray(i)
next i

Something along those lines should work, if you're looking for the result I
mentioned above.
 
Back
Top