How can I force all fields to grow to the largest "can grow" size

J

jasonfoz

Hi all;

I have a report, many fields. If I set all "can grow" properties to
"yes", then the fields grow fine. Problem is, I need the other fields
to grow to the same size as the largest field for asthetic reasons.

Also, how would I set the "can grow" property of a combo box I am
using in the report?

Thanks one and all.
Jasonfoz
 
R

Rick Brandt

Hi all;

I have a report, many fields. If I set all "can grow" properties to
"yes", then the fields grow fine. Problem is, I need the other fields
to grow to the same size as the largest field for asthetic reasons.

Don't use the borders of your TextBoxes to create the "grid". Set the borders
to transparent and use code to draw the lines using the report's line method.
Also, how would I set the "can grow" property of a combo box I am
using in the report?

Since a ComboBox can never display more than a single line of text there should
be no reason for this. In fact there is not really any good reason to use a
ComboBox on a report anyway.

If you are using it to display one value while your control holds another then
there are other (better) ways to accomplish that. Either add another table to
the report's query containing the desired value or use DLookup().
 
D

Duane Hookom

To dig a little deeper into Rick's suggestion, you need code in the On Print
event of your detail section. I generally type "Border" into the tag property
of the controls that I want to border. Then my code is:

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
 
W

WestWingFan

I tried this in my GroupHeader2 section. like so:
Private Sub GroupHeader2_Format(Cancel As Integer, FormatCount As Integer)
Dim intMaxHeight As Integer
Dim ctl As Control
'Find highest control in GroupHeader2 _
that has a tag property of "Border"
For Each ctl In Me.GroupHeader2.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 GroupHeader2 _
that has a tag property of "Border"
For Each ctl In Me.GroupHeader2.Controls
If ctl.Tag = "Border" Then
Me.Line (ctl.Left, ctl.Top)- _
Step(ctl.Width, intMaxHeight), vbBlack, B
End If
Next
End Sub

But it only sizes to the first control not to the largest, field displayed
in this section. Any ideas?

Also, how would I change the size of this border to 1pt?

Thanks in advance!
 
D

Duane Hookom

Apparently you have text boxes in your GroupHeader2 section that you want to
display equal height rectangles around. Did you set all of their Tag
properties to "Border" as suggested? Also, note the code goes in the On Print
event, not the On Format event.

You can set the DrawWidth property like
Me.DrawWidth = 4
 
W

WestWingFan

Duane,

Changing to OnPrint fixed the height issue. Thank you very much. Do you have
any idea why the line is printing to the left of where the border was before?
 
W

WestWingFan

Sorry for the confusion.

Originally I had the Border Style property set to solid. This produced a
rectangle which displayed on the page. When I changed the Border Style
property to transparent and incorporated your code, the rectangle it draws
appears slightly to the right of where the original border appeared. Does
this make my response more clear?
 
D

Duane Hookom

You can modify the code to add or subtract a few twips from the X or Y values
to position the rectangles whereever you want.
 
W

WestWingFan

One twip off of the left side did the trick. Thank you so much for all of
your help!
 

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