Results 1 to 12 of 12
  1. #1
    2 Star Lounger
    Join Date
    May 2002
    Location
    Dubai, UAE, United Arab Emirates
    Posts
    105
    Thanks
    0
    Thanked 0 Times in 0 Posts

    CanGrow & Reports (Access XP Sp1)

    So how do you use the CanGrow property? I have a columnar report with a row of controls, and just one of them is likely to need the cangrow feature. Occaisionally it will need the second line, very rarely the third. My client wants boxes around the controls (Borders was the most obvious solution) but CanGrow means that the control that cangrow is a bigger box than the rest in the row - looks awful. At the moment I've consigned the report to two lines per row (wasteful) and turned off cangrow (losing some data if it needs the third line).

    Any suggestions ??

    Regards Ken.

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: CanGrow & Reports (Access XP Sp1)

    One possible solution is to put a horizontal line at the bottom of the detail (the detail section needs the "Can Grow" property turned on too), then put vertical lines between each field that reach from the top of the detail section to the bottom. I haven't tested it, but it seems to me we ran into this some time ago and used that option - only problem is I can't remember whether it worked well or not. Hopefully somebody else has a better handle on this - I agree the different size boxes are ugly.
    Wendell

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: CanGrow & Reports (Access XP Sp1)

    Line controls won't grow automatically. You can draw vertical lines in a section in the OnPrint event using the Line method of a report.

    You can use the following to do this.

    First, put this code in a standard module, so that you can use it in several reports:

    Sub DrawLines(R As Report, ParamArray xPos())
    ' Number of twips in one inch.
    Const OneInch = 1440
    ' Maximum height of a section in inches.
    Const MaxHeight = 22
    ' Loop index
    Dim i As Integer
    ' Draw vertical line at xPos(i) inches from left margin. Covers entire section.
    For i = LBound(xPos) To UBound(xPos)
    R.Line (xPos(i) * Inch, 0)-(xPos(i) * Inch, MaxHeight * Inch)
    Next i
    End Sub

    Note:
    The x-positions of the lines are passed in a ParamArray. This means you can have as many of them as you need. See below for example usage.

    Next, create an OnPrint event handler in the module behind the report:

    Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
    ' Draw vertical lines at 1", 2.5", 4", and 5.5" from left margin.
    DrawLines Me, 1, 2.5, 4, 5.5
    End Sub

    Replace the 1, 2.5, 4, 5.5 part by the positions of the vertical lines to be drawn in your report.

  4. #4
    2 Star Lounger
    Join Date
    May 2002
    Location
    Dubai, UAE, United Arab Emirates
    Posts
    105
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: CanGrow & Reports (Access XP Sp1)

    G'day All - Thanks for your time.

    You know I can't believe it's so difficult that you have to resort to code. It would seem logical to me that in a report that is rows of data when all fields are marked cangrow and one field grows, they all shold to maintain the look of the report.

    Ah well.

    Thanks again, Ken.

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: CanGrow & Reports (Access XP Sp1)

    Such is life - under MS at least.

    But I suspect that if MS had implemented it the way *you* like, somebody would have posted the question how to avoid *all* boxes from growing, because he/she didn't like boxes with lots of empty space inside.

  6. #6
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: CanGrow & Reports (Access XP Sp1)

    What was that old saying Hans?

    You can please all of the people some of the time, and some of the people all of the time, but you cannot please all of the people all of the time.

    Pat

  7. #7
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: CanGrow & Reports (Access XP Sp1)

    No offence pal.

  8. #8
    2 Star Lounger
    Join Date
    May 2002
    Location
    Dubai, UAE, United Arab Emirates
    Posts
    105
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: CanGrow & Reports (Access XP Sp1)

    Still ... I don't think it's a strange new feature to require in a columnar report, nor do I think I should have had to write code to do it.

    Edited by Charlotte

  9. #9
    2 Star Lounger
    Join Date
    May 2002
    Location
    Dubai, UAE, United Arab Emirates
    Posts
    105
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: CanGrow & Reports (Access XP Sp1)

    Hey - no offence taken and certainly none intended. I was having a dig at the software, not anyone else. I guess I miss the days of Arev, even if it was DOS.
    Regards Ken.

  10. #10
    2 Star Lounger
    Join Date
    May 2002
    Location
    Dubai, UAE, United Arab Emirates
    Posts
    105
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: CanGrow & Reports (Access XP Sp1)

    Finally . below is the code I ended up using. I entered the text "BoxMe" in to the tag field of each control I wanted Grow-Boxed in the Detail section of the report.

    Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
    Dim ctrl As Control, MaxHeight As Integer
    MaxHeight = 0
    For Each ctrl In Me
    If ctrl.Tag = "BoxMe" Then
    If ctrl.Height > MaxHeight Then MaxHeight = ctrl.Height
    End If
    Next ctrl
    For Each ctrl In Me
    If ctrl.Tag = "BoxMe" Then
    Me.Line (ctrl.Left, ctrl.Top)-(ctrl.Width + ctrl.Left, ctrl.Top + MaxHeight), RGB(0, 0, 0), B
    End If
    Next ctrl
    End Sub

    Regards Ken.

    PS. Still can't believe it needed code ...

  11. #11
    5 Star Lounger
    Join Date
    Jan 2005
    Posts
    614
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: CanGrow & Reports (Access XP Sp1)

    I think it is legitimate question - how to make THE Line thicker? Thanks

  12. #12
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: CanGrow & Reports (Access XP Sp1)

    You can use an instruction like this:

    R.Line (xPos(i) * OneInch, 0)-(xPos(i) * OneInch + 20, MaxHeight * OneInch), BF

    BF stands for Box, Filled. The + 20 makes the line (actually a filled rectangle) 20 twips = 1 point wide; you can increase the number 20 for an even thicker line.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •