Chapter 3: Building a Simple Desktop and Web Application Page 1 of 17

Chapter 3: Building a Simple Desktop and Web Application Page 1 of 17

Chapter 3: Building a Simple Desktop and Web Application Page 1 of 17 Chapter 3: Building a Simple Desktop and Web Application Understanding Access’s Approach to Application Design Unlike other members of Microsoft Office XP, Access 2002 requires that you build an application to take advantage of the product’s power as a database development platform. Word 2002 and Excel 2002 let you automate simple repetitive operations by recording Visual Basic for Applications (VBA) macros. Access 2002 supports a set of macro commands for compatibility with previous versions, but Access macros don’t use VBA. Access doesn’t capture your mouse clicks and keystrokes and turn them into a series of macro commands or VBA code. It’s up to you to design and implement the Access applications you need for your database projects. A full-scale Access application involves at least the following three basic Access object types: z Tables that store the data you or others add to the database z Forms for displaying and entering data, controlling the opening and closing of other forms, and printing reports z Reports to print detail information, summary information, or both in tables Most Access applications also use Query objects to filter, sort, and combine your data, and Module objects to store VBA code. Access 2002 forms can (and usually do) contain VBA code in a special type of Module object, called a Class Module. All objects that make up your application are stored in a container called a Database object, which is a single file with an .mdb extension, such as Northwind.mdb. Access is unique in that it can store an entire database application in a single file. Other desktop databases, such as Microsoft Visual FoxPro, require multiple files to store their objects. New Access users often find it difficult to "get a grip" on how to start developing a self-contained database application. Dealing with an unfamiliar set of objects tends to intimidate first-time database developers. Fortunately, Microsoft includes with Access 2002 various wizards that guide you, step by step, through complex tasks. One of the most accomplished of the Access wizards is the Database Wizard that creates a typical Access 2002 "starter" application from a set of prefabricated database templates. In this chapter, you use the Database Wizard to create a relatively simple but useful Contact Manager application. Then you explore the objects generated by the Wizard to gain perspective on the relationship of Access objects and learn how they’re integrated within a typical Access database application. If you’re upgrading from Access 97 to 2002, the following features introduced by Access 2000 are discussed in this chapter: z Subdatasheets, which open when you click a plus sign to the left of the first field in Table Datasheet view. Subdatasheets automatically display records of another table that’s related to the current table. z Visual Basic for Applications code editor, which Access 2002 shares with other Office applications. Access 97 and earlier used its own VBA editing window for code modules. file://J:\Alpha\chapters\JW225.html 11/5/2001 Chapter 3: Building a Simple Desktop and Web Application Page 2 of 17 NOTE This chapter assumes that you’ve already installed Access 2002. If you haven’t, see the "Access 2002 Installation" section of Chapter 1, "Access 2002 for Access 97 and 2000 Users: What’s New." Creating an Access Application from a Template File When you launch Access 2002, the new Office 2002 task pane appears at the right of the main window with the default New File page active. The New File page offers you the following options: z Opening an existing database, such as Northwind.mdb, the Northwind Traders sample database that’s located in \Program Files\Microsoft Office\Office10\Samples. z Opening a new (blank) database. z Creating a copy of a database from an existing Access file. z Using the Database Wizard to generate a new database from one of the 10 database templates included with Access 2002. Template files contain the definitions of Table, Form, and Report objects, plus the VBA code required to automate interaction of these objects. To use the Database Wizard to create a sample application from an Access 2002 template, follow these steps: 1. Choose Programs, Microsoft Access from the Start menu to launch Access 2002 with the New File task pane visible. If you don’t see the New File task pane, choose View, Toolbars, Task Pane to display it. 2. Click the General Templates link of the New from Template group (see Figure 3.1) to open the Templates dialog. 3. Click the Databases tab, and select one of the 10 database templates (*.mdz files) to build your new application from (see Figure 3.2). Access stores its templates in the \Program Files\Microsoft Office\Templates\1033 folder. This example uses the Contact Management.mdz template. Click OK to open the File New Database dialog. 4. The wizard proposes a default database with the name of the template plus a 1 suffix. The default location of the database file is your My Documents folder. Accept the default name or shorten it to Contacts.mdb (see Figure 3.3). Click Create to generate an empty Jet 4.0 database file (Contacts.mdb) and start the Database Wizard. 5. The first dialog of the Database Wizard describes the type of information that the new database stores (see Figure 3.4). Click Next to continue. 6. The second Wizard dialog lets you add or remove optional fields to each of the three tables. Optional fields appear in italic type in the list. To add or remove an optional field of the Contact file://J:\Alpha\chapters\JW225.html 11/5/2001 Chapter 3: Building a Simple Desktop and Web Application Page 3 of 17 Information table, mark or clear the check box (see Figure 3.5). Check the Home Phone field and click Next to continue. Figure 3.1 Double-clicking the General Templates link under the New from Template heading of the task pane opens the Templates dialog with the Databases page active. Figure 3.2 Select the Contact Management template in the Databases page of the Templates dialog. Figure 3.3 Shorten the default database file name, Contact Management1.mdb to Contacts.mdb. Figure 3.4 The first Database Wizard dialog offers a brief description of the new database. Figure 3.5 Add the optional Home Phone field of the Contact Information table of Contacts.mdb. NOTE You can remove only the optional fields you add. You can’t remove the standard set of fields that appear in Roman type; you receive an error message if you try. 7. The third Wizard dialog offers a selection of text colors and background colors or images for the data forms that the wizard creates. As you select an item in the list, a sample of the style appears in the dialog (see Figure 3.6). Select a form style and click Next to continue. Figure 3.6 Select the text color and background color or image for data-entry forms. 8. The fourth dialog lets you choose a style for printed reports (see Figure 3.7). Pick a report style, such as the conservative Soft Gray, and click Next to continue. Figure 3.7 Select the header and type styles for reports in the fourth wizard dialog. 9. You enter the title to appear on your forms and reports in the fifth Wizard dialog (see Figure 3.8). The default title is the name of the template file. Accept or edit the title. 10. If you have a bitmap (.bmp or .dib, device-independent bitmap) or vector (.wmf, Windows metafile, or .emf, enhanced metafile) image of a logo that’s of a size suited to the header of your reports, mark the Yes, I’d Like to Include a Picture check box. (The logo should be about 80x80 pixels or less.) Click the Picture button to open the Insert Picture dialog. Select the image file and then click OK to insert the image and close the Insert Picture dialog. file://J:\Alpha\chapters\JW225.html 11/5/2001 Chapter 3: Building a Simple Desktop and Web Application Page 4 of 17 Figure 3.8 Accept the default title to appear on forms and reports. 11. Click Next to open the final Wizard dialog (see Figure 3.9). With the Yes, Start the Database check box marked, click Finish to add the objects whose properties you’ve specified to the database file you named in step 4. Figure 3.9 Click Finish in the final Database Wizard dialog to start generation of the Contacts.mdb database. A set of progress bars displays the Wizard’s actions. The time required to complete the generation of database objects depends on your CPU’s and disk drive’s speed; it takes less than 10 seconds to finish the Contact Management database with a 667MHz Pentium III PC and a high-speed fixed-disk drive. After the Wizard completes its work, the Main Switchboard form for the completed Contact Management application appears, as shown in Figure 3.10. The Database window, which lets you manually open any of the objects in the Contacts database, is minimized at the bottom left of the display. Figure 3.10 When the Database Wizard completes its task, the Main Switchboard form opens. Touring the Contact Management Application The Contact Management application appears complex to most first-time Access users. The Database Wizard generates Table, Form, Report, and Module objects in the new database.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    17 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us