Visual Basic 6 Programming Blue Book: The Most Complete, Hands-On Resource for Writing Programs with Microsoft Visual Basic 6!:Wrapping It Up: Validation Code And The Invoices Form
function GetCookie (name)
{
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen)
{
var j = i + alen;
if (document.cookie.substring(i, j) == arg) {
var end = document.cookie.indexOf (";", j);
if (end == -1)
end = document.cookie.length;
return unescape(document.cookie.substring(j, end));
}
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
var m1='';
var gifstr=GetCookie("UsrType");
if((gifstr!=0 ) && (gifstr!=null)) { m2=gifstr; }
document.write(m1+m2+m3);
Keyword
Title
Author
ISBN
Publisher
Imprint
Brief
Full
Advanced Search
Search Tips
Please Select
-----------
Components
Content Mgt
Certification
Databases
Enterprise Mgt
Fun/Games
Groupware
Hardware
IBM Redbooks
Intranet Dev
Middleware
Multimedia
Networks
OS
Prod Apps
Programming
Security
UI
Web Services
Webmaster
Y2K
-----------
New Titles
-----------
Free Archive
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!
(Publisher: The Coriolis Group)
Author(s): Peter G. Aitken
ISBN: 1576102815
Publication Date: 08/01/98
function isIE4()
{
return( navigator.appName.indexOf("Microsoft") != -1 && (navigator.appVersion.charAt(0)=='4') );
}
function bookMarkit()
{
var url="http://www.itknowledge.com/PSUser/EWBookMarks.html?url="+window.location+"&isbn=0";
parent.location.href=url;
//var win = window.open(url,"myitk");
//if(!isIE4())
// win.focus();
}
Search this book:
Previous
Table of Contents
Next
The Invoices Form
The Invoices form will contain the following visible objects:
A list of customers from which the user can select, implemented by using the DataList control.
A Text Box for entry of the customers Purchase Order number.
A Text Box where the date is automatically entered by code.
A Text Box where the selected customers identification (the value of the CustID field in the Customers table) is entered. You find out soon how to do this automatically by using the DataList control.
A list of the wines ordered, implemented as a DataGrid control.
Three command buttons.
Some hidden controls are also required:
Two ADO Data controlsOne each for the Customers and Items tables. You access the Invoices table without an ADO Data control.
Several Text Box controlsThese serve for data transfer and temporary storage.
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:
RowSourceThe name of the ADO Data control.
ListFieldThe name of the field to display in the list. Must be a valid field in the Recordset of the ADO Data control specified by the RowSource property.
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:
Index 0:
&Save
Index 1:
&Add Wine
Index 2:
&Cancel
Next, add an ADO Data control and set its properties as follows:
Name:
AdodcCustomers
Caption:
Customers
Visible:
False
RecordSource:
Select * from Customers order by Company
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:
Name:
DataListCustomers
RowSource:
AdodcCustomers
ListField:
Company
BoundColumn:
CustID
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:
Name:
txtCustPO
Caption:
CustPO
For the date Text Box, set its properties as follows:
Name:
txtDate
Caption:
Date
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.
Previous
Table of Contents
Next
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.
Wyszukiwarka
Podobne podstrony:
23 03 20112015 Diagnoza 2 ST amnezje itp 23 03 15 do pdf odblokowanyid(58023 03 W23 03 W23 03 2011TI 03 03 23 T pl(1)03 (23)TI 03 04 23 T pl(1)więcej podobnych podstron