Results 1 to 9 of 9
  1. #1
    broon is offline Novice
    Windows XP Access 2007
    Join Date
    Feb 2011
    Posts
    6

    CreateReportControl() won't write to header section


    I have an Access 2007 report with a custom header section named SSNHeader. The SSNHeader has preset labels, textboxes, and a chart in it. I want to dynamically add labels and textboxes to the SSNHeader depending on input from a form. I'm using the following code to create the first textbox. But the control is always written to the Detail section. The SSNHeader is not recognized for some reason. I need the control to be placed in the SSNHeader section.

    DoCmd.OpenReport "Hidden_Paycheckv2", acViewDesign

    ' *** Dynamically create report controls ***
    Dim txt401k As Control
    Set txt401k = CreateReportControl("hidden_paycheckv2", acTextBox, SSNHeader, "", ER_401k, 200, 11000, 5000, 300)

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I haven't used it (don't like to create controls on the fly), but it appears that argument is supposed to be a constant, not your name. An example:

    acGroupLevel1Header

    Help has a listing.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    broon is offline Novice
    Windows XP Access 2007
    Join Date
    Feb 2011
    Posts
    6
    Using the Access constant rather than the custom name did get the textbox to show up in the right place. But the data field I'm binding the textbox to does not show up in the report. The textbox is just empty. Is there a way to bind the textbox to a specific field on the fly?

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    It appears that one of the arguments is meant to set that. Have you tried enclosing the field name in quotes?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    broon is offline Novice
    Windows XP Access 2007
    Join Date
    Feb 2011
    Posts
    6
    Enclosing the field name in quotes got the value to show up. Thanks!

    I'm having one more issue. I can set the backcolor of the textbox but I cannot set it for the label for some reason. Here's my code:

    Dim txtWc, lblWc As Control
    Set lblWc = CreateReportControl("hidden_paycheckv2", acLabel, acGroupLevel1Header, , , 500, top, 3300, 240)
    With lblWc
    .BackColor = RGB(194, 220, 255)
    .FontName = "Cambria"
    .FontSize = "9"
    .ForeColor = RGB(0, 0, 0)
    .BorderColor = RGB(0, 0, 0)
    .Caption = "Workers' Compensation"
    End With
    Set txtWc = CreateReportControl("hidden_paycheckv2", acTextBox, acGroupLevel1Header, "", "Work_Comp", 3840, top, 1620, 240)
    With txtWc
    .Format = "Currency"
    .BackColor = RGB(194, 220, 255)
    .FontName = "Cambria"
    .FontSize = "9"
    .ForeColor = RGB(0, 0, 0)
    .BorderColor = RGB(0, 0, 0)
    End With
    top = top + top_offset

    Do you know why the backcolor of the label won't change?

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    My only thought offhand is to make sure the back style is set to Normal, not Transparent.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    broon is offline Novice
    Windows XP Access 2007
    Join Date
    Feb 2011
    Posts
    6
    Good call. The BackStyle was defaulting to Transparent.

    Do you know if there is a way to hide report controls and collapse the space they would have taken up if their value is zero or null?

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    My first thought would be to play with the Can Grow/Can Shrink properties of the controls, and perhaps the section they're in.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    broon is offline Novice
    Windows XP Access 2007
    Join Date
    Feb 2011
    Posts
    6
    I don't think the Can Grow/Shrink properties will work because the report is laid out in two columns. One column contains the data I want to be dynamically displayed depending on user input and on whether the data fields have values. The second column contains a chart. I think the chart will prevent the space from collapsing. The idea is for the whole report to fit on one page per employee. Maybe this is not possible.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Columns in Report Detail Section only
    By gg80 in forum Reports
    Replies: 10
    Last Post: 08-03-2014, 07:41 PM
  2. Page Break after foot, but not for last section
    By thestappa in forum Reports
    Replies: 0
    Last Post: 11-24-2010, 03:31 PM
  3. Replies: 26
    Last Post: 11-06-2009, 10:16 AM
  4. Replies: 1
    Last Post: 10-11-2009, 08:31 PM
  5. set an exact size for a group section?
    By Coolpapabell in forum Reports
    Replies: 0
    Last Post: 08-21-2009, 08:26 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums