ACC: Updating a Table from a Second Table Using an Expression

Last reviewed: April 2, 1997
Article ID: Q103269
The information in this article applies to:
  • Microsoft Access versions 1.0, 1.1, 2.0, 7.0, 97

SUMMARY

Novice: Requires knowledge of the user interface on single- user computers.

This article describes how to create a query that updates a record in one table with data from another table, using an expression.

MORE INFORMATION

The sample query below adds data from the Current Week table to the records in the Yearly Rainfall table.

NOTE: This type of query does not work if the data being added is the result of a totaling or grouping.

  1. Create a new table with the following fields and save it as Yearly Rainfall:

          City      Inches   Last Updated
          -------------------------------
          Baroda     0.5     4/2/93
          Basildon  22.0     4/2/93
          Beaver    18.0     4/2/93
    
    

  2. Create a new table with the following fields and save it as Current Week:

          City      Inches   Week Of
          --------------------------
          Baroda     0.1     4/9/93
          Basildon   2.0     4/9/93
          Beaver     2.5     4/9/93
    
    

  3. Create a new query based on the tables Yearly Rainfall and Current Week. Join the tables on the City field.

  4. On the Query menu, click Update.

  5. Drag the Last Updated and Inches fields from the Yearly Rainfall table to the query grid.

  6. Create the following entries in the Update To row of the query grid:

          Field: Last Updated
    
             Table: Yearly Rainfall
             Update To: [Current Week].[Week Of]
          Field: Inches
             Table: Yearly Rainfall
             Update To: [Yearly Rainfall].[Inches]+[Current Week].[Inches]
    
    

  7. Save and then run the query.

    The data in the table Yearly Rainfall is now:

          City      Inches     Last Updated
          ---------------------------------
          Baroda     0.6       4/9/93
          Basildon  24.0       4/9/93
          Beaver    20.5       4/9/93
    
    

REFERENCES

For more information about Update Queries, search the Help Index for "update queries," or ask the Microsoft Access 97 Office Assistant.


Additional query words: total archive history
Keywords : kbusage QryMktbl
Version : 1.0 1.1 2.0 7.0 97
Platform : WINDOWS
Hardware : X86
Issue type : kbinfo


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 2, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.