Connecting Tech Pros Worldwide Help | Site Map

Automatically resize textbox height to fit contents on form

Newbie
 
Join Date: Nov 2008
Location: Minnesota
Posts: 31
#1: Dec 24 '08
In Access 2007, I'm using bound textboxes on a continuous form to display the contents of each record's memo field. Is there a way to automatically adjust the textbox height to fit the contents?

Thanks in advance.
missinglinq's Avatar
Moderator
 
Join Date: Nov 2006
Location: Richmond, Virginia USA
Posts: 2,997
#2: Dec 25 '08

re: Automatically resize textbox height to fit contents on form


No, there is no way to "automatically" do this. I think it would require some rather complicated code, wherein you figure, given your font size and width of your memo field's textbox, how many characters could fit in a line, how many lines you need and set the height accordingly. And after doing all this, on a Continuous form, when you change the height of the textbox on RecordA, the height of the textbox on all records would be changed!

A better solution would be to allow the user to expand the textbox on a given record, using the acCmdZoomBox command. You could use this in a number of events, but the DoubleClick event is frequently used

Expand|Select|Wrap|Line Numbers
  1. Private Sub YourControl_DblClick(Cancel As Integer)
  2.   DoCmd.RunCommand acCmdZoomBox
  3. End Sub
as well as the GotFocus event.
Expand|Select|Wrap|Line Numbers
  1. Private Sub YourControl_GotFocus()
  2.   DoCmd.RunCommand acCmdZoomBox
  3. End Sub
Welcome to Bytes!

Linq ;0)>
Reply