troubleshooting Question

trying to word wrap text in a field on a subform

Avatar of Fordraiders
FordraidersFlag for United States of America asked on
Microsoft AccessVBA
4 Comments1 Solution54 ViewsLast Modified:
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

Is it even possible ?

Thanks
fordraiders
ASKER CERTIFIED SOLUTION
Anders Ebro (Microsoft MVP)
Microsoft Developer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros