![]() |
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() |
![]() |
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!
Listing 23.4 Modified ButtonClick event procedure for the Toolbar. Private Sub Toolbar1_ButtonClick(ByVal Button As Button) Dim Reply As Integer Select Case Button.Caption Case Customers frmCustomers.Show Case Wines frmWines.Show Case Orders frmInvoice.txtCustPO.Text = frmInvoice.txtDate = frmInvoice.Command1(0).Enabled = False frmInvoice.Command1(1).Enabled = False frmInvoice.Show Case Exit Reply = MsgBox(Quit program - are you sure?, _ vbYesNo + vbQuestion, Quit?) If Reply = vbYes Then End End Select End Sub Only a few lines of code are executed when the user clicks on the Orders button. The first code line clears the txtCustPO and txtDate Text Boxes. The captions that you placed in those Text Boxes were intended only to help identify the controls during program design, and are not needed during program execution. Two of the Command Buttons are disabled, and then the final line displays the Invoices form that you just designed. You have plenty more to add to this form, but youve gone far enough at this point to test the form to see how the DataList control works. Start the program and click on the Orders button on the Toolbar. The form that you just created appears, and a list of customers is displayed in the DataList control. Click on a company name, and its CustID is displayed in the Immediate Window. This is how you obtain the CustID for the Invoices record; remember that CustID is the field that links the Customers and the Invoices tables. Connecting To The Items TableThe form needs a connection to the Items table, of course, and you use another ADO Data control for this purpose. Add the ADO Data control and set its properties as follows:
Again, set the controls ConnectionString property to point to the GRAPEVINE database. Now you need three Text Box controls to be bound to the fields in the Items table (the fourth field, ItemNo, is automatically generated by the database engine, because it was defined as an AutoIncrement field). Add the following Text Box controls to the form: For the Quantity field:
For the InvNo field:
For the StockNo field:
The Visible property for all of these Text Boxes is set to False, because the user doesnt need to see themthey are used only as temporary storage locations for data that is being put in the Items table. You will soon see how this is done. One more thing related to the Items table needs to be discussed. When the user starts a new invoice and begins selecting wines, you want to display a list of the wines (items) that have already been selected. The ideal control for this purpose is the DataGrid control. Add a DataGrid control to the Invoices form, along the bottom edge, and set its properties as follows:
At this stage your Invoices form will look like Figure 23.1. The next task is to create the form that will allow the user to select wines to add to an invoice. The Select Wine FormAfter the Invoices form is displayed and the user has started a new invoice by selecting a customer, you need a way to select the individual wines that make up the order. For each wine, you need the quantity and the stock number to insert into the Items table. (The other two fields in this table are the item number (ItemNo), which is automatically generated by the database engine, and the invoice number (InvNo), which is obtained from the Invoices table.) To select a wine, use the same technique that you used earlier: allow the user to select from a list. Youll again use the DataList control, to display the Description field from the Wines table and provide the Stock Number of the selected wine.
|
![]() |
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. |