Walk Lightly on this PLANET and yet leave such a FOOTPRINT that cannot be erased for thousands of Years..!!!
Visit Codstech for Cyber Security related Posts !

Visitors

Monday, August 15, 2011

VB-109 : To create Reports using Data Reports

This program is connected with the below given 2 programs also...
So , You must refer them while doing the third Program.
They are ;
  1. Program using ADO Data Control
  2. How to see Data in Grid
Come to MDI Form
You can use previous MDI Form from the above given 2 Program , or to create a new one.

(A) Program  Design :


MDI Form
Project-->Add MDI
Then select Tools--> Menu Editor . Create a Menu as per shown below:
(Create a menu with Report and Exit as the Main menus)

The created Menu Bar in MDI form will look like this :




Designing Data Environment :
We are creating Reports , using Data Reports.
Befor that , we have to design Data Environment.


Select , Project--> Add Data Environment.
We will get a Screen named "DataEnvironment1" , like this :


Right Click Connection1 to get it's Properties.
We will lead to the Data Link Property Page , and select Microsoft Jet 4.0OLE DB Provider , and Click Next.


Click Next and select the Database Name we created (Here, Student) .


Click Test Connection to check whether the connection is correct.Then click OK , to return to the "DataEnvironment1" window.
============================================
Now , we have to create a connector between Data and Report.
To do this, right click on Connection1 of the Screen named "DataEnvironment1".
Click Add Command . Then we will get ;

Again  , Right Click on Command1 to get its Properties.
Now , we will get :

Select , 
DataBase Object - Table
Object Name-Student
Click OK
Then we can see;


Now , we can see Plus (+) symbol on the left side of Command1 .
Expand that + (Plus).
Then we can see all the created fields as :


Now , Project--> Add Data Report
Then we can see a window as :


Note the 5 sections in the Data Report window.
The next step is to change the Property of DataReport Window , as ;
DataSource    - DataEnvironment
DataMember  - Command1
(Refer this figure)



===================================
Next step is to Bring necessary fields from DataEnvironment1 to DataReport1.As given below:


Note that , 5 sections are there in the DataReport1 window . 
We are bringing the fields from DataEnvironment1to Detail (Section1) , of DataReport1 window .


Here , I am bringing Name , Admission Number , Course and DOB to Section1


Arranging Fields in DataReport :


Drag details from Section1 to Section4 (That is , from Detail to Report Header)
And , arrange the fields as given below :




From the Caption Property , we can change the fields , like Capital letter etc. Here is how it did.
Select Name - Change the Caption as NAME ..
And , notice all the changed fields..in the Report Header.

Note the Tool Box in the left side.

2 Tabs are there : 

  1. General
  2. DataReport
From here, Take RPTLabel and place to Report Header of DataReport1

Its Caption is Student Report 


Now , come to MDI Form: 
(Note that , you can see two options Forms and Designers in the Project1 menu.Select the option you want to take) , as given below:


Code for MDI Form :
Select Data from Report Menu of the MDI Form , to enter Code.

Private Sub mnudata_Click()
DataReport1.Show
End Sub
Private Sub mnudetails_Click()
Form3.Show
End Sub
Private Sub mnuexit_Click()
End
End Sub

======================================================================
Run the Project :
We can see MDI Form as Main Menu .


  • Click -: Report -->Details . Then we can see;


  • Click -: Report -->Details . Then we can see;


=========================================================================

 Errors :

If found any errors while running your VB program, or want to put your comment about any  program , please click Comment section , to post

      • ====================================================================
        Back to Home   &  VB ==========================================================