By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,694 Members | 2,122 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,694 IT Pros & Developers. It's quick & easy.

Report

P: n/a
Hello! I'm trying to create a report, in which all of the textbox
controls in Detail section I'd like to resize to one size.

Here is a code (Access 2000):

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
Dim c As Control
Dim MaxH As Long
On Error GoTo 999

MaxH = MaxHeight(Me.Section(acDetail))
SetControlsHeight Me.Section(acDetail), MaxH

999:
Err.Clear
End Sub
'-----
Public Function MaxHeight(sec As Section) As Long
Dim c As Control
Dim MaxH As Long
On Error Resume Next

For Each c In sec.Controls
If c.Visible = True Then _
If MaxH < c.Height Then MaxH = c.Height
Next c
MaxHeight = MaxH

End Function
'-----
Public Sub SetControlsHeight(sec As Section, H As Long)
Dim c As Control
On Error Resume Next

For Each c In sec.Controls
If c.Visible = True Then
c.Height = H
End If
Next c

End Sub

As a result I get a row, containing textbox controls with variable
heights.
What's wrong with my code?

Thanks!

Mar 1 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Igor wrote:
As a result I get a row, containing textbox controls with variable
heights.
What's wrong with my code?


I didn't look closely at your code, but disn't catch anything jumping
out at me on a quick scan (that's not to say it's 100%, mind you).
However, if you have the cangrow and/or canshrink properties of your
text boxes in the report set to yes, this could affect the sizes that
are being printed. I would think with the code that you have I'd want
to make sure these properties are set to NO in report design view. If
you haven't, try that and see if it helps...

--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me
Mar 1 '06 #2

P: n/a
I'm not quite sure where is the most appropriate place to put the code
that you have in the Detail_Print event, but I know it won't work
there. You can't resize controls in the detail print event. You
should be able to put this code in the detail format event, or better
still in the report open event if you don't want it to run every time a
record is formatted for printing.

HTH,
Bruce

Mar 1 '06 #3

P: n/a
It doesn't work neither in the Detail_Print event, nor in then
Detail_Format event.
I can move controls (Me.TextBox.Top=277), but can't resize.
Why I can't change the height?
One of the controls can grow (CanGrow is set to Yes) and the heights of
each rows can be different.
So it doesn't better to put the code into the Report_Open event.
Really it is impossible to resize controls?

Thanks!
Igor Tsoy

Mar 2 '06 #4

P: n/a
You can resize, but it appears that the CanGrow and CanShrink
properties of the controls will override whatever you do to resize the
controls. What specifically are you trying to do? There may be a
combination of settings of CanGrow and CanShrink on the controls and
the section that they are printing in that will do what you want.
Other than that the only option I could think of would be to set
CanGrow and CanShrink both to No and then rewrite your MaxHeight
function using the TextWidth and TextHeight functions to determine what
the actual height of your controls should be at run time.

Bruce

Mar 3 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.