Let's start with a very simple example, using an uncomplicated form, and a class module that we'll construct. We're going to create a class that will encapsulate the code to handle an ADO recordset for us. What we'll do here is bind two text boxes on our simple form to two fields in the Publishers table - a single button on the form will move us on to the next record. This is all pretty simple in terms of the functionality we'll use, but the principles involved will provide us with a good idea of how to extend this method.
Take another look at this illustration:
This is what our first program will accomplish without an ADO data control. So let's get on with the coding!
1. Start a new project called
. Name the default form \Chapter12\Bindings.vbp
. Add a class module and name it frmBoundExample
. Your Project Explorer should now look like this:myBoundClass
2. Add two text boxes, a check box, and a command button to the form. Please lay out the controls like this:
Control | Property | Value |
Text box |
|
txtPubID |
|
txtPubID | |
Text box |
|
txtName |
|
txtName | |
Checkbox |
|
Show Message |
Command Button |
|
cmdMoveNext |
|
&Move Next |
So much for the form. Next - the class module.