Drawing lines around multple text boxes in Detail section

G

Guest

Hello,

I have several text boxes pressed together in the detail section of a report
that I want lines to be drawn around. I have the border set to 1 point for
all of these text boxes. They are the same height. A few of the text boxes
have large strings in them, which I want the text box to grow accordingly. I
have the "Can Grow" property set to True. This works fine. The problem I'm
having is I want all the other text boxes to be the same size so it will look
uniform. How can I achieve this?

Thanks
 
D

Duane Hookom

I would:
- select all the text boxes
- remove the borders
- enter "Border" in all of their Tag properties
- Add this code to the On Print event of your detail section:

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 all controls 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), , B
End If
Next
End Sub
 
G

Guest

Thanks! That worked like a charm! :)

Duane Hookom said:
I would:
- select all the text boxes
- remove the borders
- enter "Border" in all of their Tag properties
- Add this code to the On Print event of your detail section:

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 all controls 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), , B
End If
Next
End Sub
 
G

Guest

My problem is closest to what you have resolved below, with the difference,

I have 3 controls in a row a1, a2, a3 and another row with b1, b2, b3

All the controls are sourced to a single record.

Row b is just below a, such that if 'a' grows, then b has to move by that
much down to make way. Also, all of the controls in a, a1, a2, a3 should have
the same height after one of them is required to grow to accomodate the
longer text that one of them will have in that record.

I have tried to set the .top of the b row of the controls. The help tells me
that .top property in a report is read only.

How can this be done?
 
M

Marshall Barton

Sajit said:
My problem is closest to what you have resolved below, with the difference,

I have 3 controls in a row a1, a2, a3 and another row with b1, b2, b3

All the controls are sourced to a single record.

Row b is just below a, such that if 'a' grows, then b has to move by that
much down to make way. Also, all of the controls in a, a1, a2, a3 should have
the same height after one of them is required to grow to accomodate the
longer text that one of them will have in that record.

I have tried to set the .top of the b row of the controls. The help tells me
that .top property in a report is read only.


Why would you want to set the Top property in the Print
event? As far I can see, that is automatic if all the a
text boxes have their CanGrow property set to Yes and the
top of the b text boxes are below the bottom of the a text
boxes.

Duane's code should work as is for the a text boxes, but you
will need to change it a little to do the b text boxes too.
Set the Tag property of the b textboxes to Border2:

Private Sub Detail_Print(Cancel As Integer, PrintCount As
Integer)
Dim intMaxHeight As Integer
Dim intMaxHeight2 As Integer
Dim ctl As Control

For Each ctl In Me.Section(0).Controls
If ctl.Tag = "Border" Then
If ctl.Height > intMaxHeight Then
intMaxHeight = ctl.Height
End If
ElseIf ctl.Tag = "Border2" Then
If ctl.Height > intMaxHeight2 Then
intMaxHeight2 = ctl.Height
End If
End If
Next

For Each ctl In Me.Section(0).Controls
If ctl.Tag = "Border" Then
Me.Line (ctl.Left, ctl.Top)- _
Step(ctl.Width, intMaxHeight), , B
ElseIf ctl.Tag = "Border2" Then
Me.Line (ctl.Left, ctl.Top)- _
Step(ctl.Width, intMaxHeight2), , B
End If
Next
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top