first_page the funky knowledge base
personal notes from way, _way_ back and maybe today

VB: Orange County Visual Basic Users Group Seminar; VB 6.0 Data Controls

The ADO Data Control promises to actually be useful in VB 6.0. The control can connect to a database and retrieve or modify data without code. The control only needs ConnectionString and RecordSource properties specified to run.

Several VB controls are "data aware." On text boxes, for example, the DataField and DataSource properties are used to bind to the ADO Recordset object. With Combo Box or List Box the properties are DataSource, ListField, DataField, BoundColumn, RowSource, Description, etc. This 6.0 design very much rivals the conveniences available in Microsoft Access.

The concept of events associated with a VB data control is a new concept. These are are Data Control Events:

Error
WillChangeField
FieldChangeComplete
WillMove
MoveComplete
WillChangeRecord
RecordChangeComplete
WillChangeRecordSet
RecordSetChangeComplete

Miscellaneous Notes

At design time with the DataGrid Control, use the Retrieve Fields command to get more columns from the underlying RecordSet.

Option Buttons cannot be bound to and ADO Data Control.

The Error event of the Data Control allows a centralized Error handler for Data Errors (just like in an Access form). Use Booleans to avoid cascading errors.

Miscellaneous Code

Testing an ADO Recordset's EditMode property:

blnAdding = (adoCtrl.Recordset.EditMode = adEditAdd)
If blnAdding Then
    'Adding a record...
Else
    'Not adding a record...
End If

This form is slightly faster than the If Then structure testing .EditMode directly.

Rolling your own record position caption:

With adoCtrl.Recordset
    Me.lbl1.Caption = "Record " .AbosolutePosition _
        & " of " & .Recordcount
End With
mod date: 1999-03-01T21:48:06.000Z