Results 1 to 7 of 7
  1. #1
    Join Date
    Nov 2002
    Posts
    10

    Red face Unanswered: CreateReport and CreateReportControl problems

    hi. I'm having problems with both the CreateReport and CreateReportControl functions.

    CreateReportControl:

    I try to generate a label programmatically to put on a report. Below is the code:

    Dim test As Control
    'Set test = SubMaterial
    DoCmd.OpenReport "rpt_Chart_Template", acViewDesign
    Set test = CreateReportControl("rpt_Chart_Template", acLabel, acDetail, "", "", 2, 0, 1, 1)
    test.Caption = "1 test 1"
    test.BorderStyle = 1
    test.Visible = True
    Application.Echo True
    DoCmd.OpenReport "rpt_Chart_Template", acViewPreview

    I know that the label is being created because when I test the test label's properties in debug mode, it is given a name(label1, label2, etc..), and contains the properties I set. Yet the label never shows up on the report. Any ideas on what I'm missing? I've tried to refresh, repaint, echo the screen, but the label never shows up. PLEASE HELP!

    CreateReport Function:

    I'm attempting to create a new report based on an existing template. When I run the code below, the template report appears for a split second, but when the report opens, it opens up blank with no fields and no data. What am I missing here?

    Dim rpt As Report
    Dim rptTemplate As Report
    Dim mdl As Module
    Dim lngReturn As Long
    Dim ctlLabel1 As Control
    Dim ctlText1 As Control
    Set rpt = CreateReport(, "rpt_Chart_Template")
    strReportName = rpt.name
    Application.Echo True
    DoCmd.OpenReport strReportName, acViewDesign

    Thanks in advance for your help!

  2. #2
    Join Date
    Nov 2002
    Posts
    150

    Re: CreateReport and CreateReportControl problems

    For the first problem, you need to make the last 2 parameters bigger so you can see the label. You currently have the width and heigth set to 1 pixel. Try 100 for both and keep changing from there.

    Set test = CreateReportControl("rpt_Chart_Template", acLabel, acDetail, "", "", 2, 0, 100, 100)

  3. #3
    Join Date
    Nov 2002
    Posts
    150

    Re: CreateReport and CreateReportControl problems

    Concerning issue #2, a template doesn't create controls on a new form or report. The template determines which sections a form or report will have and defines each section's dimensions. The template also contains all the default property settings for the form or report and its sections and controls.

  4. #4
    Join Date
    Nov 2002
    Posts
    10

    Thumbs up Re: CreateReport and CreateReportControl problems

    THANK YOU!!! That worked, I assumed that the height and width are inches just as they are in the properties in design view.

    Originally posted by FirstAndGoal4
    For the first problem, you need to make the last 2 parameters bigger so you can see the label. You currently have the width and heigth set to 1 pixel. Try 100 for both and keep changing from there.

    Set test = CreateReportControl("rpt_Chart_Template", acLabel, acDetail, "", "", 2, 0, 100, 100)

  5. #5
    Join Date
    Nov 2002
    Posts
    10

    Thumbs up Re: CreateReport and CreateReportControl problems

    THANK YOU!!! That worked, I assumed that the height and width are inches just as they are in the properties in design view.

    Originally posted by FirstAndGoal4
    For the first problem, you need to make the last 2 parameters bigger so you can see the label. You currently have the width and heigth set to 1 pixel. Try 100 for both and keep changing from there.

    Set test = CreateReportControl("rpt_Chart_Template", acLabel, acDetail, "", "", 2, 0, 100, 100)

  6. #6
    Join Date
    Nov 2002
    Posts
    10

    Re: CreateReport and CreateReportControl problems

    Originally posted by FirstAndGoal4
    Concerning issue #2, a template doesn't create controls on a new form or report. The template determines which sections a form or report will have and defines each section's dimensions. The template also contains all the default property settings for the form or report and its sections and controls.
    Do you mean that if I save a report with a query, and have some controls on the report, and then use this report as a template for a report, it will not copy the recordset and the controls of the template to the new report? Essentially what I want to do is copy an existing report and make modifications to the new report(without modifying the old one), I thought using the template report was the way to go - is this not the case? If so, do you have any suggestions on how to make a copy of a report and manipulate the new report without effecting the original? Thank you!!

  7. #7
    Join Date
    Nov 2002
    Posts
    150

    Re: CreateReport and CreateReportControl problems

    Originally posted by klarat78
    Do you mean that if I save a report with a query, and have some controls on the report, and then use this report as a template for a report, it will not copy the recordset and the controls of the template to the new report? Essentially what I want to do is copy an existing report and make modifications to the new report(without modifying the old one), I thought using the template report was the way to go - is this not the case? If so, do you have any suggestions on how to make a copy of a report and manipulate the new report without effecting the original? Thank you!!
    Here ya go:

    Dim strReportName As String
    Dim rpt As Report

    'create a new report to get a unique name
    Set rpt = CreateReport()
    strReportName = rpt.Name
    DoCmd.Close acReport, strReportName, acSaveNo

    'copy the template report and open in design view
    DoCmd.CopyObject , strReportName, acReport, "ReportTemplate"
    DoCmd.OpenReport strReportName, acViewDesign

Posting Permissions

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