Show/Hide Comments Text Box

  • Thread starter Thread starter thefonz37
  • Start date Start date
T

thefonz37

I'm trying to get a comments field to expand when clicking a label on a form
and then contract when it is clicked again. I have the follow code, but it's
not working.

Txt65 is the name of the control I'm trying to expand.

Private Sub Label64_Click()
If Label64.Caption = "+ Show Comments" Then
Label64.Caption = "- Hide Comments"
Text65.Height = 0
Detail.Height = 0
Else
Label64.Caption = "+ Show Comments"
Text65.Height = 50
Detail.Height = 50
End If
End Sub
 
Thanks, it was an issue with the unit of measure. I had tried setting it
even to 200 but with no noticeable difference, but setting it to 1440 makes
it do what it's supposed to.

Thanks again.
 
I notice you are also changing the size of your Detail section to match the
new size of the textbox.

Something else to watch is that (a) you can't grow a control so its bottom
(Top+Height) is greater than the Height of the section that contains it and
(b) you can't shrink a section so that its height is less than the bottom of
any control that it contains. (Hope that made sense! <g>)

For this reason, if you are growing a control, you should grow the section
FIRST, and if you are shrinking a control, you should shrink the section
LAST.

All that was a roundabout explanation for why you should switch the
following two lines:
Text65.Height = 50
Detail.Height = 50
 
Back
Top