wiklendt
i recommend chocolate
- Local time
- Tomorrow, 02:32
- Joined
- Mar 10, 2008
- Messages
- 1,746
hey,
i have some VBA which is designed to find the maximum height of label and textbox control (i have changed the label into a textbox, but its function remains as a label: this was to faciliate the max height idea but i don't know that it's helped, actually), and then make the shorter one match the taller one such that the solid colour fill of the controls are nicely as tall as one another.
now, the VBA i'm using (found externally via google, modified slightly for my own purposes) i can get it to do the fill, but not the maximum height thing.
the logic is good (i think), but i'm suspicious whether the "OnFormat" event is the correct event to put this code - i think it's drawing the 'line' BEFORE the field is grown, and thus each field colour fill ends up looking just one line tall... (see attachment). the text is showing fine, it's just the height of the drawn line.
the other thing i was thinking was maybe my "find maximum height" code was incorrect - though i personally can find no flaw in it.
any help will be appreciated. thanks.
just one last note: the label sometimes (you can see in the pdf) is the taller of the two, which is why i make VBA find the tallest control in the section before applying that height to both controls there.
i have some VBA which is designed to find the maximum height of label and textbox control (i have changed the label into a textbox, but its function remains as a label: this was to faciliate the max height idea but i don't know that it's helped, actually), and then make the shorter one match the taller one such that the solid colour fill of the controls are nicely as tall as one another.
now, the VBA i'm using (found externally via google, modified slightly for my own purposes) i can get it to do the fill, but not the maximum height thing.
the logic is good (i think), but i'm suspicious whether the "OnFormat" event is the correct event to put this code - i think it's drawing the 'line' BEFORE the field is grown, and thus each field colour fill ends up looking just one line tall... (see attachment). the text is showing fine, it's just the height of the drawn line.
the other thing i was thinking was maybe my "find maximum height" code was incorrect - though i personally can find no flaw in it.
Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
[COLOR=SeaGreen]'this code from http://www.eggheadcafe.com/software/aspnet/32844884/label-growing-problems.aspx
'major contributor: duanehooko[/COLOR]
Dim intMaxHeight As Integer
Dim ctl As Control
Dim lngColourLabel, lngColourText As Long
lngColourLabel = rgb(204, 255, 153) [COLOR=SeaGreen] 'pale green[/COLOR]
lngColourText = rgb(236, 236, 236)[COLOR=SeaGreen] 'pale grey[/COLOR]
[COLOR=YellowGreen]
[COLOR=SeaGreen]'Find tallest control in Detail section[/COLOR][/COLOR]
For Each ctl In Me.Section(0).Controls
If ctl.Height > intMaxHeight Then
intMaxHeight = ctl.Height
End If
Next
Me.DrawStyle = 6 [COLOR=SeaGreen]'transparent border, solid fill[/COLOR]
[COLOR=SeaGreen]'Draw a box around each control in Detail according to its tag property[/COLOR]
For Each ctl In Me.Section(0).Controls
If ctl.Tag = "label" Then
Me.Line (ctl.Left, ctl.Top)-Step(ctl.Width, intMaxHeight), lngColourLabel, BF
End If
If ctl.Tag = "text" Then
Me.Line (ctl.Left, ctl.Top)-Step(ctl.Width, intMaxHeight), lngColourText, BF
End If
Next
End Sub
just one last note: the label sometimes (you can see in the pdf) is the taller of the two, which is why i make VBA find the tallest control in the section before applying that height to both controls there.