Report TextBox Height - Same height for all the text boxes in a row in detail section

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AS32
    New Member
    • Jan 2016
    • 1

    Report TextBox Height - Same height for all the text boxes in a row in detail section

    I am looking to generate a report that looks like an excel printout.

    Description:
    - I need to Print a Report that has the Detail Section with 7 bordered/color coded text boxes.
    - All text boxes are 'abutted' against each other (where one ends, the next begins)
    - All text boxes have the 'can grow' property set to yes.
    Detail Section with 'can grown' = yes

    Output: Just wanted to see if there is a way to make all of these cells grow equally with the same height based on the tallest among them so that it looks good in the report.

    What code should I use in the detail section so that all of the text boxes(color coded)grow to the same height based on the tallest one among them.

    Thank you so much for your help!
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32656

    #2
    Interesting question.

    I'm not sure it's possible but you could examine the values of the various .Height properties for each of the controls within the {Section}_Forma t() event procedures when you know that at least one of the controls has been extended beyond the shortest height as designed.

    The values will be in TWIPs so don't expect them to match what it shows in your properties window. If they show as different in your examination that would lead to your requirement being possible within that same event procedure.

    Comment

    • mbizup
      New Member
      • Jun 2015
      • 80

      #3
      How about this... Set the borders of the controls to transparent, and arrange them so that they vertically span the entire detail section. Use code in the detail print event to create rectangle(s) around the controls. This shows how to do it for one. If you name your textboxes sequentially (ie: txtBox1, txtBox2, etc) you can probably use this idea and iteratively loop through your textboxes to determine the height of the tallest text box to set the y coordinates, and set the x coodinates based on the placement of each textbox...
      Code:
      Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
          Dim x1 As Integer
          Dim x2 As Integer
          Dim y1 As Integer
          Dim y2 As Integer
          
          x1 = 0
          x2 = 7 * 1440
          y1 = 0
          y2 = MyTextBox.Height
          Me.Line (x1, y1)-(x2, y2), Color, B
      End Sub

      Comment

      • zmbd
        Recognized Expert Moderator Expert
        • Mar 2012
        • 5501

        #4
        If mbizup's suggestion doesn't work in the on-print event, you may need to move it to the on-format event.

        Order of events:
        Open (report) >> Activate (report) >> Format (report section) >> Print (report section) >> Close (report) >> Deactivate (report)
        Last edited by NeoPa; Jan 10 '16, 03:25 PM. Reason: Spelling of Miriam's ID -Ade.

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32656

          #5
          The first step for me would be to determine what is reflected in the properties when the event procedure (for whichever event) is fired. I'm not sure the .Height properties are even updated to reflect any temporary growing of the controls.

          Comment

          • mbizup
            New Member
            • Jun 2015
            • 80

            #6
            >> I'm not sure the .Height properties are even updated

            NeoPa,

            It seems to depend on the event, what you're checking the height of and what you are attempting to size/resize. I tried a variety of events. The section print event definitely works - the textbox height property is updated at that point, and you can size a line/box on the fly accordingly.

            I was NOT able to get this to work however, using the section height property (which I thought might be a quick substitute for the height of the tallest textbox), nor was I able to actually resize textboxes (as opposed to drawing lines at runtime). It's possible that those might work in some combination that I did not try.

            You're right - it's definitely an interesting question!

            Comment

            • NeoPa
              Recognized Expert Moderator MVP
              • Oct 2006
              • 32656

              #7
              Thanks M. Interesting indeed. I just wonder if the Format event might allow changes where the Print event won't?

              Not that I expect you to do the experimenting. I was rather hoping to encourage the OP to do some themself. You already know the benefit of working that way. They may find the fact that you can do such things greatly empowering. So many users come from a background where any sort of debugging (Debugging in VBA) is a novel idea, but the amount of information you can discover that way is enormous.

              Comment

              Working...