Results 1 to 3 of 3
  1. #1

    Programatically setting up reports and sub reports


    here is my problem,

    I am using Access 97.

    I am trying to create an MS Access report on the fly in
    code. All I have is a report template called rpt_config
    with header and footer information set. I am attempting to
    populate the detail section of the report dynamically.

    I have got what I am attempting to do, work partly with the
    following code.

    Dim rpt As Report
    DoCmd.OpenReport "rpt_Config", acViewDesign
    Set rpt = Reports("rpt_Config")

    Now I have also set up another report template with
    text data controls that I am populating with a
    result set from a query, called rpt_detail
    (ie a line of data). I want to feed this into the main
    report (rpt_config).

    What is the code for dropping a report template into another
    report. I have successfully used the
    CreateReportControl function to drop labels onto the
    report. But, This is a hassle as I have to position every
    field individually. Is is possible to drop another
    report within an existing report in code.

    Dim labelID As Control
    Set labelID = CreateReportControl(rpt.Name, acLabel,
    acDetail, "", "",
    1151, topOffset, 396,
    labelID.Caption = "ID"

    Also, I am having trouble setting the text in Text boxes.
    I have set the ControlSource property of the TextBox
    (acTextBox) control to the return value of a record set
    field and instead of displaying the field value
    , what is displayed is "#date=". What am I doing wrong.

    Any help would be gratefully accepted.

    Thanks much

    Daniel Thomas

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Sacramento, California, USA
    Thanked 1 Time in 1 Post

    Re: Programatically setting up reports and sub reports

    Could you explain what you're trying to accomplish? Is this some kind of tool to allow users to build reports?

    You refer to
    <hr>the return value of a record set
    but it isn't clear whether you're trying to bind the textbox to a field in the recordset or if you want to insert the literal value of that field.

    I can understand wanting to design the report in code, but not populating controls with actual values. That is just a duplication of effort, since Access will kindly insert the values for you if you bind the control to a field.

  3. #3

    Re: Programatically setting up reports and sub reports


    the reason I am attemting to set and populate controls
    programatically is that the system that we have built
    is modelled using recursive relationships. There is
    a locations table with a link to another locations table
    and an intermediate lookup table since many to
    many relationships require an associative entity.( much
    like a tree structure). To complicate the issue
    further, this report requires for each location, details
    of the location and any equipment at that location.

    Each location may have 1 or more sub locations which
    in turn may have 1 or more sublocations and equipment
    levels. This can go on up to n levels.Therefore I can't
    use the standard technique of defining an access report at
    design time since I dont know how many locations there are
    and how many sub levels of locations there are. I am
    using a tree spanning algorithm to get at the data.
    Having gotten the data I have to dynmically add the specific
    details for the gotten location and its sublocations.

    I have written the particular location details to a
    temp table.
    Then with the report template that I created called
    rpt_sub, I have set the record source to this table
    and bound the text fields to the appropriate columns
    in the temp table. I ned to then know how to drop this
    into the main report (rpt_config) programatically.

    At each stage I'm repopulating the temp table.

    I hope that I have made a better attempt to explain my problem this time



Posting Permissions

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