Lesson6.15.Make-Table Queries


Lesson 6.15. Make-Table Queries

Figure 6-33. Type the name of the table you're creating in the Make Table dialog box


Figure 6-34. The make-table query


Figure 6-35. The query uses its results to create a new table.


Like all queries, a make-table query asks a question of the information in one or more tables and then retrieves results. Instead of displaying the results, however, a make-table query creates a new table with the results of the query. Make-table queries are useful for:

  • Exporting a table to another database or application.

  • Creating a backup copy of a table.

  • Creating an archive table that stores old records.

  • Creating a table that includes information or fields from more than one table.

In this lesson you will create a make-table query to create a table with information about all China tour records.

  1. Click the qryTourSales query and then click the Design button.

    The query opens in Design view. First you need to add the fields that you want to include in your new table.

  2. Double-click the TourName field in the tblTours field list, the Number of Tickets, Date, and Cost fields in the tblCustomerTours field list, and the LastName and FirstName fields in the tblEmployees field list.

    The make-table query will create a table with these fields, as shown in Figure 6-34. Next you need to specify any limiting criteria.

  3. Click the TourName column's Criteria row and type China.

    Access will add the "quotation marks" around the text string "China" for you. The make-table query will only include China tours when it creates the new table.

    Here's how to change the query type to a make-table query:

  4. Click the Query Type button list arrow and select Make-Table Query from the list.

    Access displays the Make Table dialog box, as shown in Figure 6-33. Here you need to tell Access the name of the new table.

  5. Type tblChinaTours in the Table Name box and click OK.

    You're ready to have the make-table query create the new table. Preview the results of the query first.


    Note: As with any action query you should always preview the results in Datasheet view first. Click the View button on the toolbar to display the results of the make-table query in Datasheet view.

  6. Click the View button on the toolbar to preview the results of the make-table query in Datasheet view.

    The make-table query displays the records it will use to create the new tblChinaTours table.

  7. Click the View button on the toolbar to return to Design view and click the Run button on the toolbar.

    Access asks you to confirm the creation of the tblChinaTours table.

  8. Click Yes.

    Access creates the new tblChinaTours table based on the results of the make-table query, as shown in Figure 6-35. Now let's open the new table.

  9. Close the query without saving your changes, click the Tables icon in the Objects bar, and double-click the tblChinaTours table.

    Verify the results of the make-table query, then...

  10. Close the tblChinaTours table.

QUICK REFERENCE

TO CREATE A MAKE-TABLE QUERY:

  1. IN DESIGN VIEW, CREATE A SELECT QUERY; INCLUDING ANY TABLES, FIELDS, CALCULATED FIELDS, AND CRITERIA.

  2. CLICK THE QUERY TYPE BUTTON LIST ARROW ON THE TOOLBAR AND SELECT MAKE-TABLE QUERY.

    OR...

    SELECT QUERY

    TYPE THE NAME OF THE TABLE YOU WANT TO CREATE, OR CLICK THE DROP-DOWN LIST AND SELECT A TABLE FROM THE LIST IF YOU WANT TO REPLACE THE EXISTING ONE.

  3. IF YOU SELECT AN EXISTING TABLE, CLICK ONE OF THE FOLLOWING OPTIONS:

    CURRENT DATABASE: IF THE TABLE IS IN THE CURRENTLY OPEN DATABASE.

    ANOTHER DATABASE: AND TYPE THE NAME OF THE OTHER DATABASE (INCLUDING THE PATH, IF NECESSARY).

  4. CLICK OK.

  5. CLICK THE VIEW BUTTON ON THE TOOLBAR TO VIEW THE RESULTS OF THE QUERY OR THE RUN BUTTON ON THE TOOLBAR AND CLICK YES TO CONFIRM THE CREATION.




CustomGuide Inc - Access 2003 Personal Trainer
Access 2003 Personal Trainer (Personal Trainer (OReilly))
ISBN: 0596009372
EAN: 2147483647
Year: 2005
Pages: 209

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net