![]() |
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() |
![]() |
To access the contents, click the chapter and section titles.
Visual Basic 6 Programming Blue Book: The Most Complete, Hands-On Resource for Writing Programs with Microsoft Visual Basic 6!
The Invoices FormThe Invoices form will contain the following visible objects:
Some hidden controls are also required:
Before you start, take a look at how the DataList control worksyoull be using two of them in this part of the project. The DataList Control The DataList control is similar to a regular List Box control in that it displays a list of items from which the user can select. However, the DataList control can be bound to an ADO Data control so that it automatically displays the contents of a specified field in the Recordset associated with the bound ADO Data control. Two control properties determine what the DataList control displays:
So far, so good. But wait, theres more. The DataList control has BoundColumn and BoundText properties that really make it useful. The BoundColumn property specifies a field in the bound Recordseta different field than is specified by the ListField property. When the users select an item in the DataList control, they are effectively selecting a record in the associated Recordset. The BoundText property then makes available the value of the corresponding fieldthe field specified by the BoundColumn propertyin the selected record. This is somewhat confusing, so take a look at a specific example. When a user of your program creates an invoice, the user needs to be able to select from a list of customers. To fulfill this need, youll add an ADO Data control linked to the Customers table, and then bind a DataList control to that ADO Data control. You will set the ListField property to Company and the BoundColumn property to CustID. The DataList control will display a list of names of all companies in the Customers table. When the user selects a name by clicking on it, the selected customers CustID becomes available in the DataList controls BoundText property. Starting The Form With the database project loaded, use the Insert Form command to add a new form to the project. Change its BorderStyle property to Fixed Single and its Caption property to New Order. Add a control array of three Command Buttons and set their Caption properties as follows:
Next, add an ADO Data control and set its properties as follows:
A slightly more complex SQL statement is used for the RecordSource property, to select all records from the Customers table and sort them by the Company field. Use the procedures that you learned in the previous chapter to set the controls ConnectionString property to point to the GRAPEVINE database. Note that the Caption property is a convenience that enables you to distinguish this ADO Data control from the other controls that you will be adding. (At design time only, of coursethe control isnt visible while the program is running.) Next, add a DataList control. Remember, you may need to use the Project, Components command to add this custom control to your Toolbox. Set its properties as follows:
To see how the DataList control works, you are going to print the value of its BoundText property whenever the user selects an item from the list. The place for this is in the DataListCustomers controls Click event procedure. Add the code as follows: Private Sub DataListCustomers_Click() Debug.Print DataListCustomers.BoundText End Sub The Invoices form also needs two Text Box controls, for the customers PO number and for the date: For the PO number Text Box, set its properties as follows:
For the date Text Box, set its properties as follows:
Finally, you need to add a button to the main forms Toolbar to display the Invoices form. Add a button to the Toolbar with the caption Orders and then add code to the Toolbars ButtonClick event procedure, as shown in Listing 23.4. The new code is the Case Orders statement and the lines following it.
|
![]() |
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement. |