|
Creating the Data Report
Once the Data Environment designer has been created, you
can create a data report. This sample creates a report that
could be used to print a data report that could be used as
fax cover sheet or a form letter or any other single record
data report.
On the Project menu, click Add Data Report,
and Visual Basic will add it to your project. If the designer
is not on the Project menu, click Components. Click
the Designers tab, and click Data Report to add the
designer to the menu.
Set the properties of the DataReport object according to
the table below:
| Property |
Setting |
| Name |
rptNwind |
| Caption |
Northwind Data Report |
On the Properties window, click DataSource and
then click deNwind. Then click DataMember and click Customers.
Important: To set the DataSource property to deNwind,
the Data Environment designer must be open. If it is closed,
press CTRL+R to display the Project window, then double-click
the data environment icon.
From the Data Environment designer, drag the ContactName field
(under the Customers command) onto the Report Header section
of the report designer.
Delete the Text Box control (rptTextBox) named txtContactName and rename the
Label control (rptLabel) named Label1 to lblContactName.
Do the same for the CompanyName, Address, City, Region, Postal
Code and Country fields. Finally add a picture
control that will be used to display the bar code. Name the
Picture control (rptImage) ImgBc.
Ordinarily the controls would be inserted into the Details section, the labels
deleted and the text boxes left behind so that when you run the report all
the records would show up on the report, but for this example we only want
the report to display a single record at a time, and will set the caption properties
of these labels using code when we display the report. We only want to display
one record at a time because the Picture control can only be set once and if
we displayed all the records they would all have the same bar code!
It's important to resize the height of the report sections
to be as short as possible because the height will be multiplied
for any extra space below or above the section will result
in unneeded space in the final report. After inserting all
the Labels and the Picture control your report should look
something like this:
Save the project.
|