Manually adding details to a Data Report


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.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Sorry, datareport15 above should be datareport1.
benspanAuthor Commented:

Is it possible to not have a datasource?
Hi Benspan,

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

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.