Click here to Skip to main content
15,885,546 members
Articles / Programming Languages / VBScript
Article

Create flexible and robust reports using VB's datareport utility

Rate me:
Please Sign up or sign in to vote.
3.62/5 (38 votes)
4 Nov 20012 min read 724.5K   20.4K   44   151
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


Written By
Web Developer
Pakistan Pakistan
S.S. Ahmed is a senior software engineer and works for a web and software development firm. Ahmed is a Microsoft Office SharePoint Server MVP. Ahmed specializes in creating database driven dynamic web sites. He has been creating customized SharePoint solutions for the last five years. Ahmed has worked in Visual Basic, Visual C, Java, ASP, .NET, SharePoint, InfoPath, BizTalk, etc. Ahmed enjoys travelling and has been to many parts of the world. Ahmed distributes most of his work freely to many internet sites. Ahmed also participates in different newsgroups and tries to help people out with their problems. Ahmed can be reached at share.point@yahoo.com

PEACE

S.S. Ahmed
Web: www.walisystems.com
Blog:www.sharepointblogs.com/ssa

Comments and Discussions

 
GeneralRe: Report on user input Pin
mujahidah_2829-Jul-07 20:12
mujahidah_2829-Jul-07 20:12 
GeneralRe: Report on user input Pin
oxela14-Jun-09 21:02
oxela14-Jun-09 21:02 
GeneralERROR: Invalid data source Pin
stun_dreamer5-Sep-06 20:47
stun_dreamer5-Sep-06 20:47 
Questionhow to eliminate duplicate records in combo box.. Pin
M.S.Ashok Kumar28-Aug-06 0:55
M.S.Ashok Kumar28-Aug-06 0:55 
AnswerRe: how to eliminate duplicate records in combo box.. Pin
tusprogramas716-Mar-07 16:04
tusprogramas716-Mar-07 16:04 
QuestionHOW TO GET CRYSTAL REPORT IN MY COMPONENT LIST (CRYSTAL REPORT NOT FOUND DESPITE LOADING VB6) Pin
Durgesh Haritas23-Aug-06 20:40
Durgesh Haritas23-Aug-06 20:40 
GeneralDataReport in Vb6 Pin
Durgesh Haritas23-Aug-06 20:10
Durgesh Haritas23-Aug-06 20:10 
GeneralDataGrid Pin
arman_honey22-Aug-06 19:51
arman_honey22-Aug-06 19:51 
Dear Sir/Madam

I am MCA Students and Working on My Project , I am Developing a Project in Visual Basic 6 and Backend SQL Server Database , some Problem is How to Write the Print code and what code i will write for DataGrid Data Printing ,I am Fetching a Problem When I am Using DataGrid in Vb Program , I want to take print out of Data Display in Grid using DataGrid ,I done Using DataGrid to Dispaly data from database using DataEnvironment , But Data is coming in DataGrid but plz write me code and tell me in detail how i can take print out of Data in Grid Format which Data is coming in Grid , I request you to Kindly Help me ,

Plz Help me ,


Regards,
Arman Ali
armanmallick@gmail.com
GeneralRecords repeatition in Data Report Pin
dpcwizard22-Jul-06 8:03
dpcwizard22-Jul-06 8:03 
Questioncustomized report? Pin
_kane_1-Feb-06 4:32
_kane_1-Feb-06 4:32 
Generalerror in source files Pin
math1111-Jan-06 10:43
math1111-Jan-06 10:43 
Generali,Calling VB Data Reports through ASP.NET application Pin
babatalya21-Nov-05 19:24
babatalya21-Nov-05 19:24 
Generali,Calling VB Data Reports through ASP.NET application Pin
babatalya21-Nov-05 19:20
babatalya21-Nov-05 19:20 
QuestionSequence no. generation for each record in Data Report Pin
NishthaSH17-Oct-05 19:44
NishthaSH17-Oct-05 19:44 
AnswerRe: Sequence no. generation for each record in Data Report Pin
asdfyahoo12-Dec-05 22:13
asdfyahoo12-Dec-05 22:13 
QuestionRe: Sequence no. generation for each record in Data Report Pin
ENVIROSOFT28-Apr-07 6:08
ENVIROSOFT28-Apr-07 6:08 
GeneralReport does not when executed through exe on different machine Pin
ashishnk3-Jul-05 22:17
ashishnk3-Jul-05 22:17 
GeneralRe: Report does not when executed through exe on different machine Pin
ashishnk3-Jul-05 22:23
ashishnk3-Jul-05 22:23 
GeneralStrings in DataReport Pin
Jose A Martin14-Jun-05 2:28
sussJose A Martin14-Jun-05 2:28 
Generalgenerating reports Pin
vbguru126-Jun-05 21:22
vbguru126-Jun-05 21:22 
GeneralRe: generating reports Pin
jo008330-Apr-06 21:59
jo008330-Apr-06 21:59 
GeneralDynamic Data Report Pin
Anonymous20-May-05 2:18
Anonymous20-May-05 2:18 
Generaldatareport on bv Pin
keyur aytoda16-May-05 17:28
susskeyur aytoda16-May-05 17:28 
GeneralReport sections do not match the data source. Pin
therama5-May-05 9:04
therama5-May-05 9:04 
Generalrepeat the different data from one field Pin
expertiestobe4-May-05 21:16
expertiestobe4-May-05 21:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.