Home

Microsoft Access: Updating a Record

 

Introduction

To change a record on a table using SQL, you use the following formula:

UPDATE TableName
SET    Columnname = NewValue;

The UPDATE and the SET operators are required. Here is an example:

UPDATE Employees
SET HourlySalary = 20.85;

When you execute this code, all records would have their HourlySalary value set to 20.85.

If you want to update only one particular or only some columns, use the following formula:

UPDATE TableName
SET    Columnname = NewValue
WHERE  Condition;

The WHERE operator allows you to specify a criterion that would help to identify the records whose value must be changed. Here is an example:

UPDATE Employees
SET HourlySalary = 20.85
WHERE EmployeeNumber = 825502;

This time, only the record whose EmplyeeNumber 825502 will be changed.

The Update Query

You can use an action query, called an Update Query, to update one or more records. To create an Append Query, start a query in the Design View. In the Query Type section of the Ribbon, click the Update button Update. When creating the query, you will have to set a condition that Microsoft Access will apply on a table to find out what record(s) need(s) to be updated. To do this, you use the Criteria box of a column:

Update Query
UPDATE Cars SET Cars.Condition = "Must be Retired"
WHERE (((Cars.[Car Year])<=2005));

 

 

Home Copyright © 2008-2012 FunctionX