Label Growing Problems

B

Ben

I have three memo labels on my report that I have growing with their related
memo field. ActionItems, ActionItemsOverdue, Other.

The code works below works as in it allows the label to grow with the Memo.
My problem is that after the label grows I want the border to change to
hairline for each Label.

Code Below:

Dim lngHeight As Long
Dim lngHeight1 As Long
Dim lngHeigh2 As Long

Dim X1 As Single
Dim Y1 As Single
Dim Y2 As Single
Dim X2 As Single

Dim A1 As Single
Dim A2 As Single
Dim A3 As Single
Dim A4 As Single

Dim B1 As Single
Dim B2 As Single
Dim B3 As Single
Dim B4 As Single


Me.DrawStyle = 0

lngHeight = Me.Action_Items.Height
lngHeight1 = Me.ActionItemsOverdue.Height
lngHeight2 = Me.Other.Height


X1 = ActionItems_Label.Left
A1 = ActionItemsOverdue_Label.Left
B1 = Other_Label.Left

X2 = ActionItems_Label.Left + ActionItems_Label.Width
A4 = ActionItemsOverdue_Label.Left + ActionItemsOverdue_Label.Width
B4 = Other_Label.Left + Other_Label.Width

Y1 = ActionItems_Label.Top
A2 = ActionItemsOverdue_Label.Top
B2 = Other_Label.Top


Y2 = ActionItems_Label.Top + lngHeight
A3 = ActionItemsOverdue_Label.Top + lngHeight1
B3 = Other_Label.Top + lngHeight2
Me.Line (X1, Y1)-(X2, Y2), 12632256, BF
Me.Line (A1, A4)-(A2, A3), 12632256, BF
Me.Line (B1, B4)-(B2, B3), 12632256, BF


Thanks,
Ben
 
D

Duane Hookom

If we can assume the label borders are being drawn with the Line method, you
should be able to set the DrawWidth property to skinny the line.
 
B

Ben

Duane,
I have the following code and the code from before

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

How do I get these two to work together and draw the line around the box?

Ben
 
D

Duane Hookom

That looks like my original code. Why do you want to "draw the line around
the box"? A box should already be a line. Perhaps you are referring to some
other kind of box.
 
B

Ben

Duane,
The box is a memo field with accompanying label. I changed the border on
all the fields to Transparent and put Border on each Tag. It doesn't seem to
work right.

Ben
 
D

Duane Hookom

Do you want to put separate borders around each of the labels associated with
the memo text boxes? Do they all have their own border? Have you tried
entering "border" in the tag property of the label controls?
 
B

Ben

Duane,
I want the label box to grow with the memo box and have a border around
both, but have the background of the Label be gray.

I have the following Fields

ActionItems_Label
ActionItemsMemo
ActionItemsOverdue_Label
ActionItemsOverdueMemo
Other_Label
Other_Memo

Each of the labels need to grow with the field and also produce a border
around it and have a background color of gray.

Thanks

Ben
 
D

Duane Hookom

What results do you get that make you think " It doesn't seem to work right"?
Are the labels to the left of the memo text boxes? Is that why you want them
to grow vertically?
 
B

Ben

The labels expand and they get borders drawn, but when I have it "paint" the
background with gray, the lines on the perimeter go away. It looks like the
boxes don't draw correctly. The bottom box, OtherMemo doesn't have a bottom
line drawn around the box. So it all looks weird.

Need to figure out how to get the Line code and the other code to work.


Ben
 
D

Duane Hookom

If you want a line around the label as well as a fill, you may need to use
the Line method twice. Have you tried this?
 
B

Ben

No I haven't. Tell me what I need to do. Do I just copy and paste the code
again but put the last Me.Line code to vbGray, BF?

Ben
 
B

Ben

Here is my code. This does not work at all. The label grows with its
respective memo field, but the background of the memo is gray, not the label.
The lines seem heavy and it doesn't appear to look good.

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

Dim intMaxHeight1 As Integer
Dim ctl1 As Control
'Find highest control in Detail section _
that has a tag property of "Border"
For Each ctl1 In Me.Section(0).Controls
If ctl1.Tag = "Border" Then
If ctl1.Height > intMaxHeight1 Then
intMaxHeight1 = ctl1.Height
End If
End If
Next
'Draw a box around each control in Detail _
that has a tag property of "Border"
For Each ctl1 In Me.Section(0).Controls
If ctl1.Tag = "Border" Then
Me.Line (ctl1.Left, ctl1.Top)- _
Step(ctl1.Width, intMaxHeight1), 12632256, BF
End If
Next

Again, what I want to do is have the Label of each memo field (3 of them)
grow with the memo. I want the Label to fill with gray in the background and
draw a box around the label too. Finally, I want the background to be none
on the memo fields and the lines around everything to look good and hairline.

Thanks

Ben
 
D

Duane Hookom

Set the label tag to BorderFill and try code like:
Dim intMaxHeight1 As Integer
Dim ctl1 As Control
'Find highest control in Detail section _
that has a tag property of "Border"
For Each ctl1 In Me.Section(0).Controls
If ctl1.Tag = "Border" Then
If ctl1.Height > intMaxHeight1 Then
intMaxHeight1 = ctl1.Height
End If
End If
Next
Me.DrawWidth = 1
'Draw a box around each control in Detail _
that has a tag property of "Border"
For Each ctl1 In Me.Section(0).Controls
If ctl1.Tag = "Border" Then
Me.Line (ctl1.Left, ctl1.Top)- _
Step(ctl1.Width, intMaxHeight1), vbBlack, B

End If
If ctl1.Tag = "BorderFill" Then
Me.Line (ctl1.Left, ctl1.Top)- _
Step(ctl1.Width, intMaxHeight), vbBlack, B
Me.Line (ctl1.Left, ctl1.Top)- _
Step(ctl1.Width, intMaxHeight1), 12632256, BF
End If

Next
 
B

Ben

Duane,
We're getting closer. It looks like it's almost there. The Label does the
fill in gray, but not the line around the label. It's almost like one and
not the other.

Ben
 
B

Ben

Duane,
I got it to work about 99%. The code I have modified is below. The Label
expands and fills in with Gray and draws the line. Now my problem is that
the memo fields have a strange line cutting thru the middle of them. Not
sure why. Here's the code:

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

End If
If ctl1.Tag = "BorderFill" Then
Me.Line (ctl1.Left, ctl1.Top)- _
Step(ctl1.Width, intMaxHeight1), vbBlack, B
Me.Line (ctl1.Left, ctl1.Top)- _
Step(ctl1.Width, intMaxHeight1), 12632256, BF
End If

Next

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
Me.DrawWidth = 0
'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
If ctl.Tag = "BorderFill" Then
Me.Line (ctl.Left, ctl.Top)- _
Step(ctl.Width, intMaxHeight), 12632256, BF
Me.Line (ctl.Left, ctl.Top)- _
Step(ctl.Width, intMaxHeight), vbBlack, B


End If

Next

Thanks

Ben
 
D

Duane Hookom

My most recent reply had you looping through the controls only once. I'm not
sure why you have "doubled" the code. I don't think you need anything else
from first reference to "ctl"
For Each ctl In Me.Section(0).Controls
 

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