Report

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Igor

    #1

    Report

    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(Ca ncel As Integer, PrintCount As Integer)
    Dim c As Control
    Dim MaxH As Long
    On Error GoTo 999

    MaxH = MaxHeight(Me.Se ction(acDetail) )
    SetControlsHeig ht Me.Section(acDe tail), 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 SetControlsHeig ht(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!

  • Tim Marshall

    #2
    Re: Report

    Igor wrote:
    [color=blue]
    > As a result I get a row, containing textbox controls with variable
    > heights.
    > What's wrong with my code?[/color]

    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

    Comment

    • bruce@aristotle.net

      #3
      Re: Report

      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

      Comment

      • Igor

        #4
        Re: Report

        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

        Comment

        • bruce@aristotle.net

          #5
          Re: Report

          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

          Comment

          Working...