Professional Documents
Culture Documents
And
Data Report Designer
Vivek Gupta
IT & Systems Group
Indian Institute of Management
Lucknow
Page 1 of 22
Using
DataList, DataCombo &
DataGrid Controls
Page 2 of 22
DataList Control
Allows us to display multiple rows of data in the same control,
giving us a 'pick list' of values.
Automatically filled with a field from a specified data
control.
Selections from the list box can then be used to update
another field from the same data control or, optionally, used
to update a field from another data control.
Is not the same as the standard list control, which is not
data bound.
To load this control, select Components from the Projects
menu, then select from the Components dialog box:
DAO Version:
Microsoft Data Bound List Controls
ADO Version:
Microsoft DataList Controls
5
DataList Control
Page 3 of 22
DataList Control
One use for the data bound list control is to fill the list (ListField)
from the database (RowSource), then allow selections.
BoundColumn is the field name from the source table record used
as a link.
DataSource is the recordset linked by the BoundColumn (it can be
the same recordset as RowSource or another recordset).
Then, DataField is the field in DataSource that is linked by
BoundColumn.
DataCombo
Nearly identical to the data bound list box.
Primary difference between the two controls is the
way data is displayed:
the combo control has a list box portion and a text box
portion that displays the selected item, and,
with the combo control, the user is (optionally) given
the opportunity to type in a choice not in the list box.
to load this control, select Components from the
Projects menu, then select from the Components
dialog box:
Page 4 of 22
DataCombo
Description
VbComboDropDown
VbComboSimple
VbComboDropDownList
When using Style = 1, make sure you sufficiently size the control (so
the list box portion appears) when it is placed on the form.
When to use the combo control instead of the list box control?
an excellent data entry control.
advantage over list box:
DataGrid
One of the most useful data bound controls.
It can display an entire database table,
referenced by a data control.
10
Page 5 of 22
DataCombo
DataList
Multiline textbox
DataGrid
12
Page 6 of 22
Application description
The DataCombo control on the Vendors form lets the user
choose the name of a vendor from a drop-down list.
If the user clicks on the New button on the Vendors form,
the New Vendor form is displayed so the user can enter a
new vendor.
If the user clicks on the Delete button on the Vendors form,
the current record is deleted. However, this button is disabled
if the vendor has any unpaid invoices.
The DataList control on the Vendors form displays the
invoice numbers for all of the selected vendors unpaid
invoices.
The DataGrid control on the Vendors form displays detail
information for all of the selected vendors unpaid invoices.
The multi-line text box is just a text box with its MultiLine
property set to true. In this application, it is used to display
some of the fields in the vendor record.
13
DataMember
DataField
Description
The name of the data source that the control is
bound to. This is usually a data control or a
DataEnvironment object
If you select a DataEnvironment object for the
DataSource property, use this property to
select the Command object that you want to
use
The name of the field that the control is
bound to.
14
Page 7 of 22
RowMember
ListField
Description
The name of the data source that provides the
data to be displayed. This is usually a data
control or a DataEnvironment object.
If you select a DataEnvironment object for the
RowSource property, use this property to
select the Command object that you want to
use.
The name of the field in the data source thats
displayed by the control.
15
BoundText
DataFormat
MatchEntry
Style
De s c riptio n
The field defined by the RowSource property
that is used to pass data to the field defined
by the DataSource and DataField properties.
This property returns or sets the value of the
current field specified by the BoundColumn
property
Determines the format in which the bound
data is displayed.
Determines how the data in a control is
searched as text is entered.
(DataCombo only) Determines whether the
list portion of a combo box drops down or is
fixed. It also determines whether text can be
entered into the text portion of the box.
16
Page 8 of 22
18
Page 9 of 22
DataGrid notes
You use the DataSource property of the DataGrid
control to establish its source of data. This
property provides the name of the ADO data
control that the grid is bound to.
Once you bind a DataGrid control to an ADO
data control, you can use the Retrieve Fields
command in the DataGrids shortcut menu to add
fields to the grid with each field as one column in
the DataGrid.
If you choose the Edit command from its shortcut
menu, the DataGrid enters into UI-active mode.
In this mode, you can use the commands in the
UI-active shortcut menu to change the layout of
the columns and rows in the DataGrid control.
The Cut, Copy, Paste, Delete, Insert, and Append
commands in the UI-active shortcut menu let you
manipulate the columns in a DataGrid control.
19
20
Page 10 of 22
Property
AllowAddNew
AllowDelete
AllowUpdate
Caption
DataField
Locked
AllowSizing
Alignment
FormatType
21
Database Reports
Users expect to have the ability to obtain printed
copies of information contained within a database.
This information is in the form of database reports.
Generating reports is a straightforward task.
We just need to determine what information we want in
the report and how we want it to be presented.
22
Page 11 of 22
This Data Report ability lets us build a report preview screen, with
print and export (even to the Internet) capabilities from an ADO data
environment (it will not work with the DAO or ADO data control).
All we need to do is provide the data and establish the layout.
With future releases of VB, the Data Report is sure to become the
accepted standard for database reports.
Like a Form, the Data Report has its own set of properties and
methods that control its appearance and use.
The steps involved in using Data Report:
The ADO Data Report capabilities are vast and using them is a
detailed process.
23
Page 12 of 22
25
Page 13 of 22
28
Page 14 of 22
T h e d e sig n o f a re p o rt
30
Page 15 of 22
32
Page 16 of 22
De s c riptio n
The current page number
The total number of pages
The current date (short format)
The current date (long format)
The current time (short format)
The current time (long format)
The report title (from the Title property of
the DataReport object)
33
34
Page 17 of 22
35
36
Page 18 of 22
Section
Pro pe rty
TopMargin
BottomMargin
LeftMargin
RightMargin
ForcePageBreak
KeepTogether
De s c riptio n
The margins of the report in
twips. By default, the margins
are set to 1440 (about one inch).
Forces a page break before or
after the section. The available
settings are rptPageBreakNone,
rptPageBreakBefore,
rptPageBreakAfter, and
rptPageBreakBeforeAndAfter.
Causes the section to begin
printing on the following page if
the whole section wont fit on
the current page.
37
38
Page 19 of 22
40
Page 20 of 22
41
Arg ume nt
ShowDialog
Range
PageFrom
PageTo
De s c riptio n
Determines if the Print dialog box is displayed
before the report is printed.
Determines what pages of the report are printed.
The available settings are rptRangeAllPages
(the default) and rptRangeFromTo.
The numbers of the first and last pages to be
printed. If you omit PageFrom, the report is
printed from page 1. If you omit PageTo, the
report is printed through the last page.
42
Page 21 of 22
Notes
You can issue the Show or PrintReport method from a form or
standard module.
You can also export the text in a report to a file using the
ExportReport method.
43
44
Page 22 of 22