Manually adding details to a Data Report

Posted on 2004-11-24
Last Modified: 2010-05-02

I'm trying to dump some simple data on a datareport.

I don't want to have to connect to a database or any datasource at all if i can.
just want to use the pretty's of the report layout and manually post some data to it.

Question by:benspan
    LVL 5

    Accepted Solution

    You can do this, but it requires some fiddling about. The first thing is that the datareport must be attached to a datasource - this is a limitation of the datareport itself. The way round this is to

    Create a dataenvironment command which only retrieves 1 record - you can do this by setting the max records property (on the advanced tab of the command properties window).

    Alternatively, you can create the datasource within your code, and populate it with a single record. The thing to remember is that data is irrelevant, we are only using it to get around the datareport limitation.

    Assign this datasource to your datareport

    Add labels onto the report itself. We need to use labels to contain the report information as text boxes can only be populated from a data source.

    You can then populate the labels from your code. In the example below, I have set up 6 labels (3 in the report heading, 2 in the report body)....

    With DataReport11.Sections("Section2")                         ' Report header
        .Controls("Label1").Caption = "Surname"
        .Controls("Label2").Caption = "Forename"
        .Controls("Label3").Caption = "Title"
    End With

    With DataReport15.Sections("Section1")                        ' Report body
        .Controls("Label4").Caption = "Smith"
        .Controls("Label5").Caption = "John"
        .Controls("Label6").Caption = "Mr"
    End With

    DataReport1.Visible = True

    Hope this helps

    LVL 5

    Expert Comment

    Sorry, datareport15 above should be datareport1.

    Author Comment


    Is it possible to not have a datasource?
    LVL 5

    Expert Comment

    Hi Benspan,

    No, you must have a datasource, if you don't then the datareport will error when you run it.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
    You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now