The Bound Text Box

Visual Studio 6.0

Now that we have our ActiveX ADO data control up built, we need to connect it to a bound control. Like a standard ADO data control, the only piece missing is the visual representation of the database field values. Let's bind a text box to our new control and test everything out.

Try It Out - Binding a Text Box

1.  Click on the text box to provide focus, then bring up the Properties box. Select the DataSource property and voila! Our control is there as a data source for our text box, just like the data control. Now even we VB 6.0 database programmers can create any sort of data bound control we can think of.

Since the control is data aware, by clicking the DataField property of the text box, all of the available fields are listed. Our control knows about all of the fields in the Titles table of the Biblio.mdb file:

2.  Select Title.

When you try to run the program, you must remember this is in a Project Group. Right click on the hostPrj.vbp and click Set as Start Up. Even when you do this, when you run the project you will get this enigmatic error:

Wait! Didn't we just set the project with our form, frmHost as the startup for the project? Yes, but the default startup for our control is Sub Main(). Since there is no Sub Main(), you must select the Startup Object for dataCtl.vbp and set it to None. This has caused many programmers to pull out whatever hair they have left.

© 1998 by Wrox Press. All rights reserved.