Automatically resize textbox height to fit contents on form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • postman
    New Member
    • Nov 2008
    • 63

    Automatically resize textbox height to fit contents on form

    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
    Recognized Expert Specialist
    • Nov 2006
    • 3533

    #2
    No, there is no way to "automatica lly" 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

    Code:
    Private Sub YourControl_DblClick(Cancel As Integer)
      DoCmd.RunCommand acCmdZoomBox
    End Sub
    as well as the GotFocus event.
    Code:
    Private Sub YourControl_GotFocus()
      DoCmd.RunCommand acCmdZoomBox
    End Sub
    Welcome to Bytes!

    Linq ;0)>

    Comment

    Working...