trying to word wrap text in a field on a subform

Fordraiders
Fordraiders used Ask the Experts™
on
trying to word wrap text a field in a subform
access 365

I'm trying to word wrap a field on a subform
using the code below.
I have tried the before_update  and  form_current

Private Sub Form_Current()
' MAX AMOUNT OF CHARACTERS UNTIL THE TEXTBOX WILL WORD WRAP
Const INCREASE_LINE_HEIGHT = 50
' ORIGINAL HEIGHT OF THE TEXTBOX
Const ORIGINAL_HEIGHT = 0.2035
' USED TO CONVER INCHES TO TWIPS
Const TWIPS = 1440
' USED TO DETERMINE THE SIZE OF THE TEXT BOX HEIGHT
Dim line_count As Integer
' holds text box text
Dim txtData As String
' holds textbox character length
Dim txtLength As String
' holds the number of times the text size should increase
Dim boxlines As Integer
' assign text box text
txtData = Nz(Me.WWG_Additional_Description, "")
' assign textbox length
txtLength = Len(txtData)

' if the amount of characters is created than increase the line height, then the text box size needs to be increased
' else the textbox goes back to its original state
If txtLength > INCREASE_LINE_HEIGHT Then
' get the amount of new lines required rounded up by 1
   boxlines = Int(txtLength / INCREASE_LINE_HEIGHT) + 1
' resized the textbox by the multiplying  the original height * the number of new lines * twips
   Me.WWG_Additional_Description.Height = ORIGINAL_HEIGHT * boxlines * TWIPS
Else
' default to original state
   boxlines = 1
   Me.WWG_Additional_Description.Height = ORIGINAL_HEIGHT * TWIPS
End If
End Sub

Open in new window


Is it even possible ?

Thanks
fordraiders
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
John TsioumprisSoftware & Systems Engineer

Commented:
Because some wrong assumptions may arise can you give a screenshot of what you are after?
Distinguished Expert 2017

Commented:
Giving us code that may or may not work doesn't really help.  What EXACTLY are you trying to do?  Are you trying to replicate Word's ability to adjust text to fit in a certain space and make it look "pretty"?  Why not export your report to work and let Word solve your problem for you?  You can make a word template with bookmarks and place the text in the bookmarks.

Uploading your database so we can see the code in action would also help.  But please tell us what is wrong with what your current results are.
Stephan Leban already made something along those lines, and you can find his solution here:
Autosize Textbox

Author

Commented:
THANKS ALL.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial