MS Access

Course Process

Let us understand how to create queries in this chapter.

Create an Update Query

You can use an Update Query to change the data in your tables, and you can use an update query to enter criteria to specify which rows should be updated. An update query provides you an opportunity to review the updated data before you perform the update. Let us go to the Create tab again and click Query Design.

Query Design

In the Tables tab, on the Show Table dialog box, double-click on the tblEmployees table and then close the dialog box.

Close Dialog Box

On the Design tab, in the Query Type group, click Update and double-click on the field in which you want to update the value. Let us say we want to update the FirstName of “Rex” to “Max”.

Design Tab Max

In the Update row of the Design grid, enter the updated value and in Criteria row add the original value which you want to be updated and run the query. This will display the confirmation message.

Update Records

Click Yes and go to Datasheet View and you will see the first record — FirstName is updated to “Max” now.

First Record

Create a Delete Query

You can use a delete query to delete data from your tables, and you can use a delete query to enter criteria to specify which rows should be deleted. A Delete Query provides you an opportunity to review the rows that will be deleted before you perform the deletion. Let us go to the Create tab again and click Query Design.

Query Design

In the Tables tab on the Show Table dialog box, double-click the tblEmployees table and then close the dialog box.

Property Sheet

On the Design tab, in the Query Type group, click Delete and double-click on the EmployeeID.

Employee Id

In the Criteria row of the Design Grid, type 11. Here we want to delete an employee whose EmployeeID is 11.

Description

Let us now run the query. This query will display the confirmation message.

Display Query

Click Yes and go to your Datasheet View and you will see that the specified employee record is deleted now.

Specified Record

Create a Make Table Query

You can use a make-table query to create a new table from data that is stored in other tables. Let us go to the Create tab again and click Query Design.

Query Design

In the Tables tab, on the Show Table dialog box, double-click the tblEmployees table and then close the dialog box.

Make Table

Select all those fields which you want to copy to another table.

Another Table

In the Query Type, select the Make Table option button.

Make Table Button

You will see the following dialog box. Enter the name of the new table you want to create and click OK.

Enter New Table

Now run your query.

Run Your Query

You will now see the following message.

Undo Command

Click Yes and you will see a new table created in the navigation pane.

Created New Table