Update query access 2003 examples




















Press the down arrow key to select the TourID field's third Criteria row, type 3 , press the down arrow key to select the TourID field's fourth Criteria row and type 9. Access updates the selected records by raising both their Normal Price and First Class Price fields by 10 percent. Let's open the new table. Close the query without saving your changes, click the Tables icon in the Objects bar, and double-click the tblTours table.

Compare your table with figure. Notice that the prices of four European tours have been increased by ten percent. An query. Access asks you to confirm the record update.

The update query In this lesson you will create an update query to raise the prices of all trips to Europe by 10 percent. From the Database window, click the Queries icon in the Objects bar and click the New button.

The New Query dialog box appears. Select Design View and click OK. Double-click the tblTours table and click Close. Now you need to convert the select query to an update query. Furthermore, when you update data from one table to another and use compatible data types instead of matching data types, Access converts the data types of those fields in the destination table. As a result, some of the data in the destination fields may be truncated deleted. The section Restrictions on data type conversions lists the ways in which you can and cannot convert data types.

The table in this section also explains when converting a data type can change or eliminate some or all the data in a field, and what data might be eliminated. Add the names of your destination fields to the Field row of the query design grid. The steps in this section assume the use of two similar tables. In this example, the Clients table is located in a database that you just inherited, and it contains more recent data than the Customers table.

You can see that some of the manager names and addresses have changed. For that reason, you decide to update the Customers table with the data from the Clients table. As you continue, remember that although the data types for each table field do not have to match, they must be compatible.

Access must be able to convert the data in the source table into a type that the destination table can use. In some cases, the conversion process might delete some data. For more information about restrictions when you convert data types, see the section Restrictions on data type conversions. Note: The following steps assume the use of the two preceding sample tables. You can adapt the steps to fit your data.

Double-click your source and destination tables to add them to the query. Each table appears in a window in the query designer. In most cases, Access automatically joins related fields in a query. To manually join fields that contain related information, drag the related field from one table to the equivalent field in the other table.

Access creates a relationship between those fields in the two tables and uses that relationship to join any related records. In the destination table, double-click the fields that you want to update. Each field appears in the Field row in the query design grid. If you use the sample tables, you add all fields except the Customer ID field. Notice that the name of the destination table appears in the Table row of the design grid.

In the Update To row of the query, in each of the columns that contains a destination field, add the name of the source table and the field in the source table that corresponds to the field in the destination table, and make sure that you use this syntax: [ Table ].

This figure shows part of the design grid, using the sample tables. Note the syntax for the table and field names in the Update To row. As you continue, remember that you must spell the table and field names in the Update To row correctly, and you must match any punctuation in the original table and field names.

However, you do not have to match capitalization. The following table lists the data types that Access provides, explains any restrictions on how to convert data types, and briefly describes any data loss that might occur during conversion. Text must consist of numbers, valid currency, and decimal separators. The number of characters in the Text field must fall within the size set for the Number field.

The Memo field must contain only text and valid currency and decimal separators. The number of characters in the Memo field must fall within the size set for the Number field. Values must not be larger or smaller than what the new field size can store. Changing precision might cause Access to round some values.

The dates that you can convert depend on the size of the number field. Remember that Access stores all dates as serial dates, and it stores the date values as double-precision floating integers. Access uses December 30, as date 0. Dates outside the range April 18, and September 11, exceed the size of a Byte field. Dates outside the range April 13, and September 16, exceed the size of an Integer field. To accommodate all possible dates, set the Field Size property of your Number field to Long Integer or greater.

Values must not exceed or fall below the size limit set for the field. For example, you can convert a Currency field to an Integer field only when those values are greater than and do not exceed 32, The value -1 Yes converts to December 29, The value 0 No converts to midnight AM. If the original text contains a valid Web address, such as adatum. Access tries to convert other values, meaning that you see underlined text, and the cursor changes when you point at the link, but the links don't work.

Not allowed when a Number field is part of a relationship. If the original value is in the form of a valid Internet Protocol IP address four number triplets separated by a period: nnn. Not allowed when the AutoNumber field is part of a relationship. The resulting links do not work. If you try to run an action query and it seems like nothing occurs, check the Access status bar for the following message:.

By default, Access disables all action queries update, append, delete, or make table queries unless your database is in a trusted location or the database is signed and trusted. If you have not taken either of these actions, you can still enable the query for the current database session by clicking Enable Content on the Message Bar. Creates an update query that changes values in fields in a specified table based on specified criteria.

An expression that determines the value to be inserted into a particular field in the updated records. An expression that determines which records will be updated. Only records that satisfy the expression are updated. UPDATE is especially useful when you want to change many records or when the records that you want to change are in multiple tables. You can change several fields at the same time.



0コメント

  • 1000 / 1000