Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set all text boxes in subreport to tallest 1

Status
Not open for further replies.

GPM4663

Technical User
Aug 9, 2001
165
GB
Dear all,
I have a continuous subreport in a report that has 4 text boxes per record. I have each of the text boxes set to cangrow = yes and canshrink = yes. All boxes are memo fields and depending on the contect txtBox1 may be taller than txtbox2 or visa versa etc. I was hoping to be able to set the height of each box to the tallest in code so that all the text boxes appear to make an evenly spaced table. Here is my code but it doesn't seem to work:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim intCommentHeight, intActionHeight, intWhoHeight, intNewHeight As Integer
Dim ctl As Control

intCommentHeight = Me.comment.Height
intActionHeight = Me.action.Height
intWhoHeight = Me.who.Height

If intCommentHeight >= intActionHeight Then
intNewHeight = intCommentHeight
Else
intNewHeight = intActionHeight
End If

If intWhoHeight >= intNewHeight Then
intNewHeight = intWhoHeight
End If

Me.comment.Height = intNewHeight
Me.action.Height = intNewHeight
Me.who.Height = intNewHeight
Me.when.Height = intNewHeight

End Sub

Any help would really be appreciated. I attached a screen shot of what I am trying to avoid.

thanks

GPM


 
I thought I had already replied in this thread but I don't see it. You can't get the grown height of a control in the On Format event. This is only available in the On Print event which is too late since you can no longer set the height of a control in this event.

You can remove the borders of all controls and use code as follows. This code assumes you have entered the word Border into the tag property of the controls you want bordered.

Code:
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
    Dim intMaxHeight As Integer
    Dim ctl As Control
    'Find highest control in Detail section _
      that has a tag property of "Border"
    For Each ctl In Me.Section(0).Controls
        If ctl.Tag = "Border" Then
            If ctl.Height > intMaxHeight Then
                intMaxHeight = ctl.Height
            End If
        End If
    Next
    'Draw a box around each control in Detail _
      that has a tag property of "Border"
    For Each ctl In Me.Section(0).Controls
        If ctl.Tag = "Border" Then
            Me.Line (ctl.Left, ctl.Top)- _
                Step(ctl.Width, intMaxHeight), vbBlack, B
        End If
    Next
 
End Sub

Duane
Hook'D on Access
MS Access MVP
 
Duane,
Thanks for that its a big help.

cheers,

GPM
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top