![]() |
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() |
![]() |
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!
Finally, set the ADO Data controls Caption property to Customers and its Align property to vbAlignBottom. This last property causes the control to align itself automatically at the bottom of whatever form it is on. Now you can set the properties of the other controls on the Customers form. Generally, the properties are left at their default settings. Here are the most important changes you need to make:
Save the form as CUSTOMER.FRM, and assign a Name property of frmCustomers. Be sure to set the forms MDIChild property to True, to make it a child of the MDI form that you created earlier, and change the Caption property to Customers Table. Designing The Wines FormConceptually, the Wines Form is quite similar to the Customers form that you just created. However, for the Wines form, you will implement one new technique: you will use a Combo Box in place of a Text Box for data entry for some of the fields. You can consider a Combo Box as a combination of a Text Box and List Box; users can either type data into the Text Box part of the control or select from the drop-down list of items. A Combo Box is appropriate when the data entry into a particular field (either usually or always) consists of an item from a predefined list. This is the case for the Color and Type fields in the Wines table. Note that using a Combo Box does not force a selection from the listusers can always type something elsebut using a Combo Box does make the entry of list items faster and error-free. Select Insert Form to add a new form to the project. The forms Name property should be set to frmWines, and it should be saved under the name WINES.FRM. This form will contain the following controls:
After placing the controls, the form should look like Figure 22.11. Here are the most important changes you need to make to the form and control properties:
Designing The List FormPart of your design plan is to have the ability to list all the records in both the Wines and the Customers table. You included a List All button on both the Customers and Wines forms, but how can you implement a list of all records? The DataGrid control provides the ideal solutionit is designed for just this kind of task. You will create a single form for listing records, and then specify which tables records are to be displayed in code before the form is displayed. Add a new form to the project. Set its Name property to frmList and save it as LIST1.FRM. Add one DataGrid control, one ADO Data control, and one Command Button control to the form. Set the DataGrids DataSource property to ADODC1 and its Align property to Top. The ADO Data controls ConnectString should be set to the GRAPEVINE.MDB database, as you have done for the other ADO Data controls. The ADO Data controls RecordSource property, however, doesnt need to be set at this time, because it will be set in code. You should make the ADO Data controls Visible property False, however, because you wont need this control to be visible on the form. Change the Command Buttons Caption property to &Finished. Writing The CodeNow that you have designed the projects first three forms, you can turn your attention to writing the code that gives these forms their functionality. Of course, these three forms are only part of what the project requiresso why not design the remaining forms before starting on Basic code? This is one approach, but my own experience has proven that working on the project one section at a timeboth forms and codegives better results. This way, you have part of the program working properly before moving on to the next part. You can expect to have to make changes later. You already have enough forms designed to provide part of the programs functionality, such as entering, editing, and listing records in the Customers and Wines table. Making sure that this much is working before you move on to the next challenge is a good idea. The Basic ModuleComplex projects such as this one almost always require a Basic module for declaration of global variables and similar tasks. To add a Basic module, select Add Module from the Project menu. Type the following code: True when entering a record, False otherwise. Global EnteringRecord As Boolean Save the module under the name GRAPEVINE (Visual Basic adds the .BAS extension). Coding The Customers FormThe initial approach to coding this form is to provide its basic functions, but not necessarily everything that you eventually want it to include. Youll write code to permit users to enter, edit, delete, and list records, and leave the code writing for data validation until later.
|
![]() |
Products | Contact Us | About Us | Privacy | Ad Info |