VB6 beginners tutorial - Learn VB6

Advanced VB6 tutorial - Learn Advanced VB6

Systems Analysis - System analysis and Design tutorial for Software Engineering

Browse Topics

- Getting started
- Data Types
- Modules
- Operators in VB6
- VB6 Variable
- VB6 Procedures
- VB6 Control Structures
- Loops in VB6
- VB6 Exit Do & With End With
- Arrays in VB6
- User-Defined Data Types
- VB6 Constants
VB6 Built-in Functions
- Date and Time in VB6
- VB6 Controls
- TextBox Control
- ComboBox & OptionButton
- Label & Frame
- PictureBox & ImageBox
- Timer Control
- ListBox & ComboBox
- VB6 ScrollBar
- Control Arrays in VB6
- Files controls in VB6
- VB6 CheckBox
- Forms in VB6
- Menus in VB6
- MDI Form in VB6
- InputBox
- MessageBox
- Mouse events
- Mouse Move
- Error Handling
Error Handling (2)
VB6 Database

You are here: Visual Basic > VB6 (Beginners Tutorial)

Tutorial Main Page | Previous Page | Contents | Next Page

Custom Data Aware Controls - VB6 Database Tools

• As mentioned earlier, there are three custom data aware tools, in addition to the standard Visual Basic tools: the DataList, DataCombo, and DataGrid ADO tools. We’ll present each of these, giving their suggested use, some properties and some events. If the icons for these tools are not in the toolbox, select Project from the main menu, then click Components. Select Microsoft DataList Controls 6.0 (OLEDB) and Microsoft DataGrid 6.0 (OLEDB) in the Components window. Click OK - the controls will appear.

• Like the data control, previous versions of Visual Basic used DAO versions of the list, combo, and grid controls, named DBList, DBCombo, and DBGrid. Make sure you are not using these tools.

• DataList Box:

The first bound data custom tool is the DataList Box. The list box is 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.

Some properties of the DataList box are:

DataSource - Name of data control that is updated by the selection.

DataField - Name of field updated in Recordset specified by DataSource.

RowSource - Name of data control used as source of items in list box.

ListField - Name of field in Recordset specified by RowSource used to fill list box.

BoundColumn - Name of field in Recordset specified by RowSource to be passed to DataField, once selection is made. This is usually the same as ListField.

BoundText - Text value of BoundColumn field. This is the value passed to DataField property.

Text - Text value of selected item in list. Usually the same as BoundText.

The most prevalent use of the DataList box is to fill the list from the database, then allow selections. The selection can be used to fill any tool on a form, whether it is data aware or not.

As a quick example, here is a DataList box filled with the Title (ListField) field from the dtaExample (RowSource) data control. The data control is bound to the Titles table in the BIBLIO.MDB database.

DataCombo Box:

The DataCombo Box is nearly identical to the DataList box, hence we won’t look at a separate set of properties. The only differences between the two tools is that, with the DataCombo box, the list portion appears as a drop-down box and the user is given the opportunity to change the contents of the returned Text property.

DataGrid Tool:

The DataGrid tool is, by far, the most useful of the custom data bound tools. It can display an entire database table, referenced by a data control. The table can then be edited as desired.

The DataGrid control is in a class by itself, when considering its capabilities. It is essentially a separate, highly functional program. The only property we’ll be concerned with is the DataSource property, which, as always, identifies the table associated with the respective data control. Refer to the Visual Basic Programmer’s Guide and other references for complete details on using the DataGrid control.

As an example of the power of the DataGrid control, here’s what is obtained by simply setting the DataSource property to the dtaExample data control, which is bound to the Titles table in the BIBLIO.MDB database:

At this point, we can scroll through the table and edit any values we choose. Any changes are automatically reflected in the underlying database. Column widths can be changed at run-time! Multiple row and column selections are possible! Like we said, a very powerful tool.


Tutorial Main Page | Previous Page | Contents | Next Page


Home | About Us | Privacy Policy | Contact Us

Copyright © | All Rights Reserved