Ana səhifə

What you will do: Plan and design a Microsoft Access 2000 database


Yüklə 1.37 Mb.
tarix18.07.2016
ölçüsü1.37 Mb.


A
What you will do:


  • Plan and design a Microsoft Access 2000 database.



  • Create a table
    using a Microsoft Database Wizard.



  • Modify the table by adding new data categories.



  • Use a form to add data to your database table.



  • Create and run a query.



  • Create and print a new report.



  • Create a Data Access Page.


ccess 2000

Whether you want to organize your educational records, maintain departmental information, or coordinate class projects, an Access 2000 database provides the structure and flexibility you need. You can store all kinds of information in an Access 2000 database, use queries to analyze the data, and create professional reports with customized layout and graphics.

New Web features in Access 2000 also enable you and your students to collaborate on projects. Using the built-in features of Access 2000, you can display information from the database on the Web and students can input data into a database from the Web. In fact, students can build a database collaboratively with students all over the country using Data Access Pages.

When you are finished with this lesson you will have a database to store census information. In the process you will learn to:



  • Use the Table Design Wizard.

  • Add Fields to the Table.

  • Add Data to the Table.

  • Use a Form to view and add data to your table.

  • Query a database for specific information.

  • Customize a report on data in a database.

  • Create a Data Access Page to view and share database information on the Web.

New for 2000

Access 2000 has several new and improved features that make it even easier to view and share information from a database. These features include:



  • Improved wizards. The wizards help you create tables, forms, and queries and are even more intuitive to use.

  • Name AutoCorrect. When you rename a field (column) in a table, the change is automatically updated in all dependent tables, queries, and forms.

  • Drag and Drop to Excel. You can export data from Access 2000 to Excel 2000 simply by dragging the Access 2000 objects into Excel 2000 (tables, queries, and so on). This feature is convenient when you maintain information on your students in both Access 2000 and Excel 2000 and you need to transfer some data from one file to another.

  • Compact on close. Databases can grow in size quickly and take up space on your hard disk. Access 2000 automatically compresses a database when the file is closed to reduce the file size. This is especially useful when space on the hard disk is limited and you are storing databases for a number of classes.

  • Report snapshot. You can create snapshots of Access 2000 reports that can be distributed to a disk, printer, Web page, or e-mail.

  • Data access pages. Creating Web pages from the objects in your database is a simple process using this new feature in Access 2000. Now your students can view and add information to a class database easily from your school intranet or from home.

Exploring Access 2000

To use Access 2000 effectively, you should be familiar with the structure of a database. A database consists of a collection of tables, queries, forms, reports, and pages that you use to manage and present data. These components are also called database objects. When you build a database, you create as many of these objects as you need and Access 2000 stores them in one database file. Each object you create in the database is dependent on other objects. That is, a query, form, or report draws information from tables, so changing data in any one of these objects changes the data in all of these objects. Because the objects in a database are related to one another, building a database requires careful planning.

In fact, it only makes sense to build a database when you need a flexible system for organizing and analyzing data. For example, when you are teaching three sections of one subject and you want to grade all three classes on one curve, it makes sense to store your records in a database instead of in an Excel 2000 workbook. You can store information on each class in separate tables and connect them by a common field. Then you can use a query to analyze student performance in all three classes.

There are seven main components of a database in Access 2000:



  • Tables. Use tables to store database information.

  • Forms. Use forms to enter or edit the information in your tables. Forms let you view one record at a time.

  • Reports. Use reports to deliver a professional presentation or written report to your class.

  • Queries. Filter data so that you retrieve selected records or fields from the database.

  • Pages. Create HTML pages from a database quickly and efficiently.

  • Macros. Automate tasks that you perform on a regular basis in a database.

  • Modules. Automate a group of related procedures in Access 2000.

You create and open database objects from the Access 2000 database window, which lists the objects in the left pane of the window. When you click on one of the first five items, the right pane gives options for creating the object, and it shows all existing objects of that type in the database. You can open an object by double-clicking it.


In this chapter, you first learn about tables in Access 2000. Later, you learn about forms, queries, reports, and pages. Macros and modules are features for advanced Access 2000 users. You can learn more about them with the help of the Office Assistant after you are familiar with the objects in a database.



Setting up a database

To get started with Access 2000, you can create a database for a class project to conduct a census. Students can gather information from interviews and store it in a database, then compare the results with city census results from the past four decades. They can use Access 2000 queries to analyze how demographics vary in different neighborhoods and how they have changed over time.



To create a database

  1. Start Access 2000.

  2. In the Microsoft Access dialog box, select Blank Access 2000 database and click OK.

  3. In the File New Database window, decide where you want to store the database on your computer and name the database Student Census.

  4. Click Create.

When you click Create, the Student Census database opens. You can now create and store tables, forms, reports, and queries in the census database.

Exploring tables

The first object to add to your database is a table. You use tables to store all the data in the database. Each row of a table contains one record. Records are made up of fields that contain a particular piece of data in the table. For example, when you create the census database, all the data for one household will be stored in a record. One field in the table might specify the number of people in the household or the neighborhood where the household is located.

Every table in Access 2000 must have a field that uniquely identifies each record in the table. This field is called the primary key. You can recognize the primary key in a table by the ID appended to it. The primary key ensures that you can retrieve data accurately and efficiently when you pull information from the database. Access 2000 automatically assigns a primary key to each of your records for you when you use an Access 2000 Table Wizard.

Viewing tables

There are two ways to view your table: Datasheet view and Design view. When you double-click a table object from the Access 2000 database window, it opens in Datasheet view.

Use Datasheet view when you want to view, add, or delete data from a table. You can also reformat your table to change the size and order of the field columns in this view.

Datasheet view



Design view

Use Design view when you want to change the structure of a table. You can add or delete fields, change a field caption or size, or select the type of data you plan to enter into a field in Design view.





Creating tables

When you open a database, you see three options for creating a table:



Unless you are already familiar with Access 2000, you should use the Table Wizard when you create tables.

The Table Wizard helps you to organize data by providing sample fields that you can include in a table and it assigns a primary key to each record. Later, if you need to change the design of your table, you can modify it using Design view. The Table Wizard even provides a sample student table that you may want to build after you have finished designing the census database.



To create a table using the Table Wizard

  1. From the objects box in the Student Census database window, click Tables.

  2. Double-click Create table by using wizard. The Table Wizard dialog box opens.

  3. C

    Scroll through the sample tables in the Table Wizard. You can get ideas for other tables you may want to create in Access 2000 in the future.




    lick each of the tables in the Sample Tables list and scroll through the Sample Fields list.



  4. When you see a field that you want to include in your table, click it and then click the single right arrow next to the Sample Fields list. If you want to include all of the Sample Fields in one table, simply click the double right arrow.

  5. If you accidentally add a field that you don’t want or add the same field twice, click it in the Fields in my new table list and then click the single left arrow to remove it.

  6. When you are satisfied with the fields in the table, click Next. If you need to later, you can modify the fields in the table using Design view.

  7. The Table Wizard provides a name for the table. Replace this name by typing Census Table.

  8. Make sure the option for the Table Wizard to assign a primary key is selected and then click Next.

  9. Click Finish to exit the Table Wizard.

The census table appears in Datasheet view.

Navigating in the table

Before you enter data into a table, you need to know how to move around in it. Depending on what you want to do, you can use the TAB key, the navigation buttons at the bottom of the table, the arrow keys, or the HOME, END, PAGE UP, and PAGE DOWN keys.

To move within a record


  • To select any field, click it.

  • To move one field to the right, press TAB or use the right arrow key.

  • To move one field to the left, press SHIFT+TAB or use the left arrow key.

  • To move to the first field of the active record, press HOME.

  • To move to the last field of the active record, press END.

To move from record to record

  • To move to the next record, click the single right arrow next to Record.

  • To move to the previous record, click the single left arrow next to Record.

  • To move to the first or last record in the table, click the First Record or Last Record icon next to Record.

  • To move one window down, press PAGE DOWN.

  • To move one window up, press PAGE UP.

Changing a table in Design view

When you use the Access 2000 Table Wizard, chances are that you will not be able to design the table exactly as you like it. In the census, for example, you may want to include information on ethnicity and income, two fields that are not available from the Table Wizard Sample Fields list.

To modify a table, you must open it in Design view by selecting the table you want to modify from the main window of Access 2000 and then clicking Design, or if the table is already open, click the Design icon in the left corner of the table window.

To add a field to a table


  1. Open the table in Design view.

  2. Click in the first empty row of the Field Name column.

  3. Type the field name. Press the DOWN ARROW to move to the next empty row if you want to add another field. A data type will automatically be assigned to the field (which you can change later).

  4. If the fields are in the wrong order, you can click to select a field and then drag it to where you want it to appear.

  5. When you have finished adding fields, save and close the table.

To delete a field from the table, select the entire row by clicking the leftmost box and then press the DELETE key.

To rename a field to your table

  1. Open the table in Design view.

  2. Select the row containing the field name you want to change by clicking it.

  3. Type the new field name in the Caption box under Field Properties.

  4. S

    ave and close your table.

With the new AutoCorrect feature, the field name change is automatically updated in all queries, forms, reports, and pages that draw information from the table you have modified.

Setting a data type

The data type determines the kind of data that can be entered into a field. It also formats the value you enter for the data type. For example, when you enter numbers in a field with a currency data type, the dollar and decimal signs will be automatically added to the numbers. Some of the more common data types are:



  • Text. Any combination of letters and numbers.

  • Currency. Numbers and monetary symbols. You can only add numbers to a field with a currency data type.

  • Date/Time. The date and the time in 12- hour and 24- hour formats.

  • Yes/No. A single value that indicates yes or no, true or false.

For information on the other data types, ask the Office Assistant.

Each field in an Access 2000 table must be assigned a data type. The fields you select from the Table Wizard already have a data type assigned to them. Text is the default data type for any fields you add to your table.



To set a data type

  1. Open the table in Design view.

  2. Click in the data type column of the field for which you want to set a data type.

  3. C
    lick the arrow in the data type text box to see the drop-down list of data types.



  4. Select the data type you want from the drop-down list.

  5. Save and close the table.

Setting field properties

Each field in a table is defined by a set of properties. These properties determine the size of the field, how it is formatted, and what it is called, among other things. You can view or change field properties in Design view.



To set field properties

  1. O

    If you want more information on options for designing your table, look at the lower right pane of the Design view window. When you click on a field, a note appears in the pane to describe what you can do in that field.


    pen the table in Design view.

  2. Select the field for which you want to set properties.

  3. Click the General tab in the Field Properties window.

  4. Click the property you want to modify and type the appropriate text. Do one or more of the following:

  • Type a number in the Field Size box to indicate the maximum number of characters that field can hold.

  • Select Y or N in the Required box to indicate whether data must be entered in this field for every record.

  • Type the caption you want for a field in the Caption box. This caption appears on the tables and forms. If you do not enter a caption, the field name appears as the caption.

  1. After you have set the field properties, save and close your table.

To add data to a table

  1. Open the table in Datasheet view.

Press TAB to move from the primary key column to the second column in the table. (You cannot add data to the primary key column. Access 2000 automatically generates the information in this column.)

  1. Type data in the second column. As soon as you enter a value into the second column, Access 2000 automatically numbers the first record and adds another record to the table.

  2. Press TAB to move to the next column in the table, and type your data. Unless a field is required, you can leave a field empty.

  3. When you reach the end of the first record, press TAB to move to the next record in the table.

  4. Save and close your table.

Deleting data from a table

You may add a field to your census table and later discover that you cannot collect data for that field, so you need to delete it from your table. Deleting fields and records in Access 2000 is simple:



  • To delete an entire record, make sure you are in Datasheet view and click the record selector in the box at the left of the record and then press the DELETE key. Then click Yes.

  • To delete an entire field from a table, go back to Design view and click the field header so that the whole row is selected and then press the DELETE key.

Sorting records

Access 2000 displays the information in a table in alphabetical or numerical order based on the primary key. However, you can sort information so that it appears in an order that works better for you. For example, if you want to group people by educational level in the census table, you can select that field and then click one of the sort buttons. Access 2000 alphabetizes the records according to the data in that field.



To sort records

  1. In Datasheet view, click the header of the field to sort by so that the whole column is selected.

  2. Click the Sort Ascending button or the Sort Descending button on the Datasheet toolbar.

  3. Save and close the file.

You can use the sort feature for query results also.

Exploring forms

F
orms make it easy for you and your students to access information in a database. With a form, you can focus on one record in a database at a time, and you can view, add, and delete data from that record. In addition, you can customize a form to view and print information in a style you like. You can create a simple multi-page form that looks like this:



Creating forms

The easiest way to build a form is by using the Form Wizard. The Form Wizard lets you choose the layout of records in the form and also the background, color, and format of the display. The Form Wizard lets you preview the layout and style options when you create a form.



To create a form

  1. From the list of objects in the census database window, click Forms.

  2. Double-click Create form by using wizard.

  3. Under Tables/Queries, select the table the form will be based on from the drop-down list.

  4. Select the fields that you want to appear in the form by clicking each one and then clicking the arrow that appears to the right of the Available Fields list. If you want all the fields from the table to appear in the form, click the double arrow and then click Next.

  5. Select the layout for your form by clicking Columnar, Tabular, or Datasheet and then click Next.

  6. Select the style of the background print you prefer and then click Next.

  7. Enter a name for the form you have created, then select Open the form to view or enter information, and then click Finish.

To open a form stored in the database, double-click it in the main database window.

Navigating a form

Many of the techniques you used for moving around in tables also apply to forms:



  • To add data to a record, click in the box in which you want to add data and then type.

  • To delete information, double-click in a box to select the text and then press the DELETE key.

  • To move from record to record, press the arrow keys next to Record at the bottom of the window.

  • T

    You can add data to a form using a screen reader utility.



    o add a record to a form, click the New Record icon on the Form View toolbar.

  • To delete a record from a form, select it by clicking the bar on the left (indicating the whole record is selected) and then press the DELETE key. Click Yes to delete.

Any changes you make to a record in a form automatically appear in the table that the form draws information from.

Finding records in a form

At times, you may want to make changes to a record in a database, but the record isn’t visible when you open your form. You can quickly find a record, or information within a record, by using Find on the Standard toolbar.



To find a record

  1. On a form, activate the field for which you plan to enter a value. For example, if you want to find the record for a person with the last name “Smith,” click in the Last Name box of the visible record.

  2. Click Find on the Standard toolbar.

  3. In the Find What box, type what you are looking for. For example, if you are looking for Linda Smith's record, select the Last Name field, then type Smith.

  4. Click Find Next to begin the search, and continue until all matches have been displayed.

  5. Click Close to stop the search and close the window.

Exploring queries

Q
ueries are great for getting information from a database. With a query, you can filter the data that you view in a table. You establish a set of criteria when you create the query. Then when you run the query, Access 2000 returns only those fields or records that are of interest to you. The results appear in a table in Datasheet view.

The following procedure shows you how to create a query that displays only a select set of fields in a table.

To create a select query in Design view


  1. From the list of objects in the Student Census database window, click Queries.

  2. Double-click Create query in Design view.

  3. In the Show Table dialog box, select the table containing the data you want to access and then click Add. You can add as many tables as you like.

  4. Click Close.

  5. In the query window, select the fields that you want to include in your query from the table list by double-clicking each one. When you double-click a field, it appears in the field columns of the datasheet.

  6. To run your query with the limited fields, click Run on the Query Design toolbar.

  7. Save and close your query.

Once you’ve created a query and saved it in the database, you never need to create that query again. Even when you change or add new records, the new data automatically appears in the query the next time you run it.

To run a query

  1. Click Queries in the database window.

  2. Double-click the query you want to run. Access 2000 runs the query and displays the results in Datasheet view.

Setting a parameter for your query

Now you have created a query that retrieves the data from a specific set of fields, but suppose that you want to see only the data within a field that meets a set of criteria. For example, you want to see the records in the census database grouped by the neighborhood where people live. A parameter query lets you set the criteria for your query when you run it.

You can add a parameter to an existing query, or create a parameter query in Design view. You add a parameter by entering a prompt in the criteria box of the field for which you want to set parameters. You must enclose the prompt in square brackets.

To create a parameter query


  1. Open the query to which you want to add a parameter by clicking it in the database window and then clicking Design in the upper-left corner of the window.

  2. Click the Criteria text box of the field you want to set a parameter for and then type the prompt that will appear when you run the query. Remember to enclose the prompt in square brackets [ ].

  3. Save the query with the added parameter and then close it.

To run a parameter query

  1. W
    ith the query open in Design view, click Run on the Query Design toolbar. Before your datasheet appears, Access 2000 displays a dialog box prompting you to enter the criteria you are interested in.




  1. Enter the value and then click OK. The datasheet opens showing only the specific information you have requested.

You have learned just two of many types of queries you can create and run in Access 2000. You can use mathematical expressions to perform calculations on your data or you can use aggregate functions, such as Avg or Sum, to calculate statistical information. To learn how to create other queries, ask the Office Assistant.

Exploring reports

After you and your students have added information to the census database, you may want your students to report on some aspect of the data they've collected. Reports let you customize the display of information from the database. You can select the data you want to include and then select the report layout from a variety of design and format options. You can insert pictures, add headers, footers, and page numbers, group the information, and change the background colors, among other things.





    When you design your first report, use the Report Wizard. The Report Wizard asks you a series of questions to help you design the data exactly as you want. After you have created the report, you can open it in Design view to modify its structure.

To create a new report

  1. From the list of objects in the Student Census database window, click Reports.

  2. Double-click Create report by using wizard.

  3. Select the table for which you want to create a report from the Tables/Queries drop-down list and then double-click the fields in the Available Fields list to add them to the Selected Fields box. Click Next.

  4. I
    f you want to prioritize the fields, add grouping levels to your report. Do this by clicking a field and then clicking the right arrow to position it at the top of the list. You can select up to four fields to appear at the top of your report.

  5. To rearrange the grouping, use the up and down Priority arrows to move fields. When you have grouped the fields according to your preferences, click Next.

  6. To order the values in a particular field, select the field from the drop-down list by clicking the arrow in the box and then click Ascending or Descending. You can sort records in up to four fields. After you indicate the sort preferences, click Next.

  7. Select a Layout style from the list of options and then click Next.

  8. Select a report style and then click Next.

  9. Type the title you want to appear on the report. The title will also be the file name for the report.

  10. Make sure Preview the Report is selected and then click Finish. The report appears in Print Preview after you click Finish.

I
f you like, you can enhance the appearance of your report by adding a picture or a hyperlink. To insert objects into a report, you must open it in Design view.

To insert a picture in a report

  1. In Design view, click the section of the report where you want to insert a picture.

  2. On the Insert menu click Picture.

  3. From the drop-down list in the Insert Picture dialog box, select the folder containing the picture. Then double-click the file you want to insert.

  4. Click OK. The picture is inserted into the selected area of the report.

Follow this same process for inserting hyperlinks, except click Hyperlink instead of Picture on the Insert menu.

To adjust the position of the picture

  1. Position the pointer over the picture until the pointer changes into a hand.

  2. To move the picture, click and drag it. Use the horizontal and vertical rulers to align the picture.

  3. Select Print Preview from the drop-down menu in the left corner to preview the report with the picture in it.

  4. When you are satisfied with the position of the picture, save and close the report.

To learn more about customizing a report, open the report in Design view then click Toolbox. Experiment with the buttons in the toolbox to see what you can do.

E

xploring Data Access Pages

With Data Access Pages, you can collect student information from the Web rather than gathering it all on paper and organizing it yourself. All you need to do is create a Data Access Page to add to a database of student records. When you save the database to a network server, your students can enter data directly into the page while viewing it in Internet Explorer 5.0. All the input students add to the Web page is immediately saved in the database.

In addition to helping you manage records, Data Access Pages make it easy for your students to collaborate on projects by providing them with an efficient way to share information. Rather than give each of your students a copy of the census database, for example, you can distribute tables from it over the Web, so your students can add data to it at school or at home. In fact, by making it available on the school intranet, students from other classes can also browse through your database and add to it, if you want them to.

Designing a Data Access Page does not require any programming knowledge. In fact, the process of creating a page is similar to that of creating a form or report. You can use the Page Wizard or create the page in Design view. You select the fields you want to appear on your page and then format it using the same tools and techniques you use to format a report.



To create a Data Access Page using the Page Wizard

  1. From the list of objects in the Student Census database window, click Pages.

  2. Double-click Create data access page by using wizard.

  3. Select a query or table from the drop-down list and then select the fields that you want to include on your Data Access Page. Click Next.

  4. You can add grouping levels if you wish, but if you do the page will not be interactive. Click Next.

  5. Select a sort order for the fields and then click Next.

  6. Type in a title for the page and then click Finish.

The Page Wizard opens the Data Access Page in Design view, where you can make changes to the format of the page. You can also add a title and text to it by clicking the title and text prompts and then typing text.

Access 2000 automatically applies the Straight Edge theme to the page, unless you select another. The theme determines the color and design elements of the page, including the bullet style and background images. You can change or remove the theme from a page in Design view. You can also apply brighter colors, change the background image, or animate graphics. To make it easier to experiment with themes, Access 2000 lets you preview your choices before you make a final selection.



To change the theme of a page

  1. With the page open in Design view, select Theme from the Format menu.

  2. Select a theme from the list in the Theme dialog box. Access 2000 displays a preview in the right pane of the dialog box.

  3. Set options for color, background, and graphics by selecting the boxes below the list of themes.

  4. When you are satisfied with the design of the theme, click OK. The page appears in Design view with the new theme applied.

To learn about other techniques for formatting a Data Access Page, ask the Office Assistant.

Saving a Data Access Page

Although you design a Data Access Page in Access 2000, the page is not stored in the database like other objects. Data Access Pages are saved as HTML files in one of the Windows desktop folders and Access 2000 adds a shortcut to the file in the database window.



To save a Data Access Page

  1. In Page view or Design view, click Save from the File menu.

  2. Double-click the folder where you want to store the HTML file.

  3. Type the name of the page.

  4. Click Save.

You can now open the HTML file you have created from your Windows desktop or from the database window.

To open a Data Access Page

  • To open a Data Access Page in Design view, click the file shortcut in the database window and then click Design.

  • To open a Data Access Page in Page view, double-click the file shortcut in the database window.

  • To open a Data Access Page in a Web browser, double-click the HTML file in your Windows desktop folder. (Your default browser must be Internet Explorer 5.0 for this option to work.)

You can view the page in a Web browser by opening it in Design view or Page view and then clicking Web Page Preview from the File menu.

Adding live data from the Web to a database

The Web offers a wealth of information to you and your students, some of which may be pertinent to a database you are constructing. For example, you may find census reports from past decades on the Web that you want to add to the database for comparative purposes. When you find a Web page that contains information that is useful for your class, you can create a Data Access Page from the Web page, and store it in the database. First, you must save the Web page on your Windows desktop.



To save a Web page

  1. Open the Web page in Internet Explorer 5.0.

  2. Click Save As from the File menu.

  3. Select the folder where you would like to save the HTML file.

  4. Change the default name of the file, if you prefer a different name.

  5. Click Save.

You can also save a Web page to the Favorites folder on your Windows desktop by opening the Web page and then clicking Add to Favorites from the Bookmark menu.

To make a Web page into a Data Access Page

  1. Select Pages from the database window.

  2. Double-click Edit Web page that already exists.

  3. Browse the folders on your Windows desktop to locate the Web page you want to open and then click Open.

The Web page opens in Design view, where you can modify it. The changes you make only appear in your Data Access Page, not on the original Web page. When you have finished making changes to it and save the HTML file, you have to rename it and select a folder in which to save it.

Putting it together

Your students can benefit from using a database for many class or school projects:



  • In a science class, design a database with data you collect when performing experiments and then create a key word search.

  • In a history class, create a simple database with information about significant individuals or events and then use reports to analyze the information.

  • In a math class, use a database to calculate statistical information.

  • In a business class, create a database on the international market, including the gross national product, import and export patterns, and unemployment rates.

  • In your school, create a database to track a school fundraiser. Use Data Access Pages so all the classes at your school can add information on their progress from the Web.

Using the Access 2000 database, you can organize school information. Examples of databases you can use include:

  • Library resources, including books, magazines, and audio information. When you use Data Access Pages and copy the database to your school network, you can peruse library holdings from the Web.

  • Student information, such as name and student number, academic records, contact information, records of disciplinary action, and medical needs or restrictions.

  • Classroom resources including curriculum objectives, text books, supplementary texts, student learning activities, and district standards.

  • Departmental information, such as the courses taught, by whom, in which classroom, and when.




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©atelim.com 2016
rəhbərliyinə müraciət