We help IT Professionals succeed at work.
Get Started

trying to word wrap text in a field on a subform

Fordraiders
Fordraiders asked
on
51 Views
Last Modified: 2019-12-05
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
Microsoft Developer
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE