I want to make a data report and i want to add the data from textbox in datareport. please help me in doing so...ThanxHow to add data from textboxes in datareports in vb?
First you have to create Data Environment.
Creating a Data Environment
1. Start a new Standard EXE project.
2. On the Project menu, click Add Data Environment. If this item is not on the menu, click Components. Click the Designers tab, and choose Data Environment and click OK to add the designer to your menu.
3. We need to point to our database. In the Data Environment window, right-click the Connection1 tab and select Properties. In the Data Link Properties dialog box, choose the database in which you have created by DB Provider. Click Next to get to the Connection tab. Click the ellipsis button. Find your database (mdb) file. Click OK to close the dialog box.
4. We now tell the Data Environment what is in our database. Right-click the Connection1 tab and click Rename. Change the name of the tab to Phone. Right-click this newly named tab and click Add Command to create a Command1 tab. Right-click this tab and choose Properties. Assign the following properties:
Command Name -
Connection -
DataBase Object - Table
ObjectName -
5. Click OK. All this was needed just to connect the environment to our database.
6. Display the properties window and give the data environment a name property of den(name). Click File and Save den(name) As. Save the environment in an appropriate folder. We will eventually add this file to our phone database management system.
After that now you have to create Data Report. Follow these simple steps:-
Once the Data Environment has been created, we can create a Data Report. We will drag things out of the Data Environment onto a form created for the Data Report, so make sure your Data Environment window is still available.
1. On the Project menu, click Add Data Report and one will be added to your project. If this item is not on the menu, click Components. Click the Designers tab, and choose Data Report and click OK to add the designer to your menu.
2. Set the following properties for the report:
Name - rpt(name)
Caption - (name)
DataSource - den(name) (your data environment - choose, don鈥檛 type)
DataMember - List (the table name - choose don鈥檛 type)
3. Right-click the Data Report and click Retrieve Structure. This establishes a report format based on the Data Environment.
4. Note there are five sections to the data report: a Report Header, a Page Header, a Detail section, a Page Footer, and a Report Footer. The headers and footers contain information you want printed in the report and on each page. To place information in one of these regions, right-click the selected region, click Add Control, then choose the control you wish to place. These controls are called data report controls and properties are established just like you do for usual controls. Try adding some headers.
5. The Detail section is used to layout the information you want printed for each record in your database. We will place two field listings (Name, Phone) there. Click on the Name tab in the Data Environment window and drag it to the Detail section of the Data Report. Two items should appear: a text box Name and a text box Name ((name)List). The first text box is heading information. Move this text box into the Page Header section. The second text box is the actual value for Name from the (name)List table. Line this text box up under the Name header. Now, drag the Phone tab from the Data Environment to the Data Report. Adjust the text boxes in the same manner. Our data report will have page headers . Under these headers, these fields for each record in our database will be displayed.
6. Click File and Save rpt(name) As. Save the environment in an appropriate folder. We will now reopen our phone database manager and attach this and the data environment to that project and add capabilities to display the report.
Accessing the Data Report
1. Reopen the phone directory project. Add a command button named cmdReport and give it a Caption of Show Report. (There may be two tabs in your toolbox, one named General and one named DataReport. Make sure you select from the General tools.)
2. We will now add the data environment and data report files to the project. Click the Project menu item, then click Add File. Choose den(name) and click OK. Also add rpt(name). Look at your Project Window. Those files should be listed under Designers.
3. Use this code in cmdReport_Click:
Private Sub cmdReport_Click()
rpt(name).Show
End Sub
4. This uses the Show method to display the data report.
Your database report is ready.How to add data from textboxes in datareports in vb?
Give a point to Bunty...
For easier and quick solution related to Visual Basic programming, be a member of http://www.vbforums.com .
I ensure you for the quick answers.
No comments:
Post a Comment