Example: Accessing Shaped Recordsets

The example in this chapter allows you to navigate manually through a three-level hierarchical recordset with the use of non-bound controls. Although the MS Hierarchical Flex Grid is very useful in some situations, as we see throughout this chapter, this control frequently offers us no help at all in our real-world applications.

Figure 9-5 shows what the Access example looks like during runtime.

The Access Shape recordset example in action
Figure 9-5. The Access Shape recordset example in action

This example allows the user to select a contact name, or customer, from a list box on the left. Programmatically, this action accesses a chapter field within the recordset that passes a child recordset to the individual orders shown in the second list box. When you select an order from this list box, another chapter field is read to return the second child recordset, the Order Details table. The Total Order Price shown in the bottom-right corner of the form is calculated using an aggregation method on the Order Details child recordset.

To begin this example, create a new project and call it prjAccessExample. Use the Project → References . . . menu item to add a reference to Microsoft ActiveX Data Objects 2.1 Library, or the most recent version that you have. In addition, you should use the Project → Components . . . menu item to add the Microsoft Windows Common Controls 6.0 to your project for the ...

Get ADO: ActiveX Data Objects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.