VB6 beginners tutorial Learn VB6 Advanced VB6 tutorial Learn Advanced VB6 Systems Analysis System analysis

and Design tutorial for Software Engineering

You are here:

Visual Basic > VB6 (Beginners Tutorial)

Tutorial Main Page | Previous Page | Contents | Next Page

Creating a Data Report in Visual Basic 6 (VB6)

• Once you have gone to all the trouble of developing and managing a have the ability to obtain printed or displayed information from your data. The process of obta known as creating a data report.

Browse Topics
- Getting started - Data Types - Modules - Operators in VB6 - VB6 Variable - VB6 Procedures - VB6 Control Structures - Loops in VB6 - VB6 Exit Do & With End
With - Arrays in VB6

• There are two steps to creating a data report. First, we need to create a Data Environment. Visual Basic and is used to tell the data report what is in the database. Second, we create the too, is done within Visual Basic. The Data Environment and Data Report files then become pa project developed as a database management system.

• The Visual Basic 6.0 data report capabilities are vast and using them is a detailed process. capabilities is best demonstrated by example. We will look at the rudiments of report creation report for our phone database. Example - Phone Directory - Building a Data Report

- User-Defined Data Types - VB6 Constants
- VB6 Built-in Functions - Date and Time in VB6

We will build a data report that lists all the names and phone numbers in our phone database creating a Data Environment, then a Data Report. We will then reopen the phone database m add data reporting capabilities. Creating a Data Environment 1. Start a new Standard EXE project.

- VB6 Controls - TextBox Control - ComboBox & OptionButton - Label & Frame - PictureBox & ImageBox - Timer Control - ListBox & ComboBox - VB6 ScrollBar - Control Arrays in VB6 - Files controls in VB6 - VB6 CheckBox - Forms in VB6 - Menus in VB6 - MDI Form in VB6 - InputBox - MessageBox - Mouse events - Mouse Move

2. On the Project menu, click Add Data Environment. If this item is not on the menu, click Co Designers tab, and choose Data Environment and click OK to add the designer to your men

3. We need to point to our database. In the Data Environment window, right-click the Conne Properties. In the Data Link Properties dialog box, choose Microsoft Jet 3.51 OLE DB Pro the Connection tab. Click the ellipsis button. Find your phone database (mdb) file. Click OK

4. We now tell the Data Environment what is in our database. Right-click the Connection1 t Change the name of the tab to Phone. Right-click this newly named tab and click Add Comm Command1 tab. Right-click this tab and choose Properties. Assign the following properties: Command Name - PhoneList Connection - Phone DataBase Object - Table

Save the environment in an appropriate folder.choose don’t type) 3. Note there are five sections to the data report: a Report Header. We will drag thin Environment onto a form created for the Data Report. Click the Designers tab. This establishes a report format Environment. 6. These controls are called data report controls and properties are established ju controls. a Detail s a Report Footer. 5.. 4. and choose Data Report and click OK to add the 2.Error Handling (2) . Line this text box up under the Name header.rptPhone Caption . click Add Data Report and one will be added to your project. On the Project menu.Error Handling . All this was needed just to connect the environment to our database. don’t type) DataMember .PhoneList 5. If this ite click Components. Phone) there.VB6 Database ObjectName . my data environment window looks like this (I expanded th clicking the + sign): Creating a Data Report Once the Data Environment has been created.choose. We will eventually add this file t management system. Right-click the Data Report and click Retrieve Structure. Set the following properties for the report: Name . Move this text box into the Page Header section. we can create a Data Report. so make sure your Data Environment w 1. Two items should appear: a text box Name and a text box Name ( box is heading information. Now. Try adding some headers. Click OK. drag the .Phone Directory DataSource . Click on the Name tab in the Data Environment window section of the Data Report.PhoneList (the table name . right-click the selected region. click Add Control. Display the properties window and give the data environment a name property of denPhon denPhone As. The headers and footers contain information you want printed in the report a place information in one of these regions. the wish to place.denPhone (your phone data environment . At this point. The second text Name from the PhoneList table. The Detail section is used to layout the information you want printed for each record in you two field listings (Name. a Page Header.

Reopen the phone directory project. Choose denPhone and click OK. Also add rptPhone. one named General and one named DataReport. 3. This uses the Show method to display the data report.) 2. Click the Project File. Thos under Designers. these fields for each record in our database will be d form should look something like this: In this form. I’ve resized the labels a bit and added a Report Header.Show End Sub 4. Click the Show Report button and this should appear: . Under these headers. Save the environment in an appropriate folder. 6. Any space left in this section will be inserted after each entry. Add a command button named cmdReport and give it (There may be two tabs in your toolbox. Save the application and run it. Click File and Save rptPhone As. Also. Use this code in cmdReport_Click: Private Sub cmdReport_Click() rptPhone. make sure you clo a single line. Adjust the text boxes in the same manner.Environment to the Data Report. Ma the General tools. We will now add the data environment and data report files to the project. We will no database manager and attach this and the data environment to that project and add capabiliti Accessing the Data Report 1. 5. Our data report w Name and Phone. Look at your Project Window.

com | All Rights Reserved . Tutorial Main Page | Previous Pa Home | Link to Us | About Us | Privacy Policy | Contact Us Copyright © 2007-2011 Freetutes. Just click the Printer icon. Notice the re displayed report and the sections available in the Data Report designer.You now have a printable copy of the phone directory.

Sign up to vote on this title
UsefulNot useful