Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Jul 2002
    Location
    Sacramento, CA
    Posts
    193
    Thanks
    3
    Thanked 1 Time in 1 Post

    Change Number of Columns Based On Data (2002 - SP2)

    I am attempting to build a master report with an embedded sub report. The master report is a single column report with a category header and an embedded sub report in the detail section. The sub report is a multi-column report printing across then down. The report prints correctly, with each category in the master report the sub categories are correctly listed beneath it across the page.

    However, I would like to micro-manage the number of columns in the sub report dynamically. Many of the sub category descriptions are very short, and can easily fit in a 10 column report. Some of the major categories have sub categories with longer descriptions and only fit in a 5 column report. In the master report record source I've added a column to obtain the maximum length of the sub category description for each major category.

    I attempt to change the number of columns with the following code in the master report:
    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    With gCurrentAppPrinter 'Global printer object set to Application.Printer
    .DefaultSize = False
    .ItemLayout = acPRHorizontalColumnLayout
    If Me!AccSubDescLen > 8 Then 'Test for a long seb category description requiring fewer columns
    .ItemsAcross = 5
    .ItemSizeWidth = 1440 ' 1"
    Else
    .ItemsAcross = 10
    .ItemSizeWidth = 770 ' 1/2"
    End If
    End With
    End Sub

    In the master report category footer I reset the column number to one.
    Private Sub GroupFooter3_Format(Cancel As Integer, FormatCount As Integer)
    With gCurrentAppPrinter
    .DefaultSize = False 'Ensure following item is editable
    .ItemsAcross = 1
    .DefaultSize = True 'Use the detail width
    End With
    End Sub

    I can step through the code and the correct values are seeminly set, but they are not impacting the sub-report layout ... it remains a 10 column report.

    I'm not sure if I've over looked some detail, this approach won't work, or the goal can not be accomplished.

    Thanks for your help.

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

    Re: Change Number of Columns Based On Data (2002 - SP2)

    I don't think this is possible. You're trying to set the properties of the global printer object, you should be setting the properties of the Printer property of the subreport, but that is not available - Printer is only a property of the main report. I very much doubt that you can change the column count of a subreport dynamically.

  3. #3
    2 Star Lounger
    Join Date
    Jul 2002
    Location
    Sacramento, CA
    Posts
    193
    Thanks
    3
    Thanked 1 Time in 1 Post

    Re: Change Number of Columns Based On Data (2002 - SP2)

    Hans,

    Thanks for your response. Was hoping for a differnt answer, but sometimes things just be be done.

    Marty

Posting Permissions

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