

We'll use the Export feature in a moment. The button on the left will Print and the one on the right will allow us to Export. Notice the two buttons at the top left corner of your report. The report will look similar to the image below. Start the project and then click the CommandButton to View Report.

Enter DataReport1.Show in the Command1_Click event.The final result will resemble the image below.
Visual basic data reports code#
Now double click the commandbutton that's on Form1 to bring up the Code Window. Choose the one on the left and drag it above to PageHeading(Section2) Repeat the same process to place LastName, FirstName, MI, Phone, Address, City, State and Zip. Now place your cursor on CustomerID - left click and hold-Now just drag over to Detail(Section1) You'll see two CustID. Go to DataSource and change the property to DataEnvironment1 and then change the DataMember Property to Command1. Adjust the size of the DataEnvironment and DataReport to resemble the image below.Ĭlick the DataReport. Go to Project and Choose Add Data Report. The final result will look like the image below. Set the DatabaseObject to Table and then set the ObjectName to Customers. Now right click on Command1 and click Properties. Right click on connection again but this time choose Add Command. If everything is on track you'll see a messagebox with the message "Test Connection Succeeded". Go to the location where you'd saved your database and double click. Now, click the button to the right where you see 1. Once opened - right click on Connection1 and choose Properties. Go to Project and choose More ActiveX Designers. Set the DataSource and DataField Properties for the remaining TextBox(s). Go to Text3 and Set the DataSource Property. (Note: All of the remaining TextBox(s) DataSource Properties will be set to ADODC1) Now go to Text2 and Set the DataSource Property. Set the DataSource Property to ADODC1 and the DataField Property to CustID. Now we'll set the DataSorce and DataField Properties to each Textbox that we'd place onto our Form1 earlier.Ĭlick Text1 and then go to the Properties Window. Now go to Table or Stored Procedure Name and choose Customers (or whatever you'd named your Table) Now just click Apply and then click OK. For the CommandType choose 2 - adCmdTable. Now, go to where you see RecordSource and left click.

If everything is on track you'll see a messagebox with the message "Test Connection Succeeded"- Press OK to close the message and then press OK again. When prompted Choose Microsoft Jet 4.0 OLE DB Provider and click Next. Choose: Use Connection String and left click Build. Right click ADODC1 control that we'd placed on Form1 and right click ADODC Properties. This expanation will help those who are doing this for the first time or maybe have forgotten a step or two. If you're wanting to Export a DataReport to Microsoft Word then I would guess that you already know the steps that need to be taken. Change the Caption of the CommandButton1 to View Report. Add the Adodc Control from our ToolBox named: ADODC1. Change the Caption Property for each Label as shown in the image below. Now add 9 Labels named: Label1, Label2, Label3 and so on. Add 9 TextBox(s) named: Text1, Text2, Text3 and so on. You will now have a this Component in your ToolBox. Add a Adodc Component by going to Projects, Components and choose Microsoft ADO Data Control. Open Visual Basic and choose: Standard EXE. (.doc) Creating our User Interface in Visual Basic 6.0 We"ll just place a few controls and in a short time we'll be able to Export our DataReport to a Microsoft Word. Now let's move on to creating a user interface in Visual Basic 6.0. Now, open the Customers Table and fill in the information you see in the image below. Now create a table by going to: Create Table in Design View and enter the Field Name(s) and Data Type(s) as shown in the image below. (.doc) Creating our Database in Microsoft Access:Ĭreate a blank database in Microsoft Access and name the database: DataReport. We'll then add a DataEnvironment and DataReport and within minutes we'll be able to export our DataReport to a Microsoft Word Document. Putting everything together should be relatively easy because we'll use Adodc Componenet to make the connection to our Database. In this article we'll create a simple database in Microsoft Access and then create a user interface in Visual Basic 6.0. How to: Export a DataReport to Microsoft Word (.doc)
