Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Create flexible and robust reports using VB's datareport utility

0.00/5 (No votes)
4 Nov 2001 1  
This application shows how to create flexible and robust reports using VB's data report utility.

Sample Image - datarep.jpg

Introduction

This project will show you how to create reports in VB using the data report utility. This utility is very easy to use and it only takes minutes to create flexible reports using this utility. For this project, I have used the biblio database that comes with VB6, so make sure that the biblio database is available on your machine in the directory where VB is installed. I have used data environment to connect to the database and the report fetches the records directly from the database (via data environment). I wanted to write a complete article about the usage of this utility but alas! the time is short. So, you will have to delve into the code yourself to see what's happening. On the main form, you will see the following four buttons:

  1. Show Report: This will display the report on the screen.
  2. Print Report: This will send the report to the printer, printer should be installed or you will get an error message saying that no printer was found.
  3. Export to HTML: This will export your report to HTML format, you can select the number of pages you want to be exported to HTML.
  4. Exit: You can exit the application by clicking this button.

You can drag the fields directly from the data environment on to your report. That's it!!!!

Creating the application

Here are the steps needed to create the project:

  1. Start a new VB project (EXE).
  2. Insert data environment and change its connection property to point towards the biblio database that comes with VB.
  3. Insert a command and point it towards the publishers table.
  4. Insert a child command and point it towards a title table.
  5. Add a data report utility from the project menu.
  6. Open the data environment and data report windows and place them side by side.
  7. To change the data report utility to better suit the data environment that was previously defined, first change the data report's datasource property to dataenvironment1 (you can change the name of the data environment) and its datamember property to publishers. Next, right click anywhere within the data report window and choose the retrieve structure option. Click yes.
  8. Change the format of the report according to your own needs.
  9. See the form's code to understand the functions that are needed to display, print and export the report to HTML format.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here