Home Know Me Snaps Feedback
 
::Online Microsoft Office,Web ,Graphic and many more Tutorials
Action Query

Action queries are queries that permit us in just one operation to perform changes on one o various rows in a table. With these queries we can create a new table including in it the records of another, change the data stored, insert new records or erase old records.this type of action query given below

Make-Table queries

Update queries

Append queries

Delete queries

Make-Table queries

A Make-Table query creates a new table with the records stored in one or more tables.
  • Open a new query in design view.
  • We add one or more tables from where we are going to extract the data to save in our new table.
  • We design the query in the same way as a normal selection query, so that only the records we want to save in the new table will appear.
  • Then, we drop down the Query menu and select the Make-Table Query... option.
    (The Make table dialogue appears: )
  • We type the name of the new table in Table Name: box.

    We normally create the table in the same database (Current database option) but we can create it in another database, and in this case we will need to check the Another database: option and type the name of the database where the table should be made in the File Name: box. It needs to be the complete name including the complete path, and therefore it is easier looking for the database using the Browse... button; click on it and search for the database where we want to save the new table.

  • Finally, click on the OK button and we return to the Query design

  • Set the Criteria if you want

  • Click on Run button
    When we run a make-table query we are advised of this, and we are also advised when a table already exists with the same name as the new one :

    The fields in the new table are named as the headers of the query fields, and inherit the same data type as the source fields but they do not inherit the properties such as the primary key, indexes, etc...
Update queries
Update queries allow us to modify the data stored in a table. In only one operation, all the records can be changed at the same time, or only those that comply with a determined condition.
  • We open a new query in design view.
  • We add the table that we would like to update.
  • We drop down the Query menu and select the Update query option.
  • The source of the query could be a table, a query, or a combination of tables.
  • In the Field grid box we only put the field or fields that intervene in the search criteria and those fields that we want to update.
  • In the Update to: row we write the expression that calculates the new value to assign to the field.
  • Criteria: Type the criteria value which you want to update.(If you not set Criteria they will update all record as same update to value)
  • If we update a defined column as part of a relationship, this column can or cannot be updated depending on the referential integrity rules.
  • In order to be able to view the data being edited before performing the update we can click on the Design view Click Datasheet view button on the toolbar or View menu >> Datasheet view option.
  • To run the query click Run button . When we run the query the changes are performed on the table.
Delete Queries

Delete queries are queries that remove records from a table.

  • Open a new query in design view.
  • Add the table from which we want to delete records.
  • Click on Query menu and select the Delete query option
  • Field: Insert the field which you want to
  • table: Select Table
  • Criteria: Type the Condination(Criteria) for delete . (If no search criteria is indicated, ALL the records are erased from the table.)
  • To run the query click on the Run button on the toolbar On running the query the query deletion from the table is performed although we are advised before that the rows are to be deleted and we can cancel the operation.
  • Once deleted, the records can not be recuperated.

    If the table where we are deleting is related to other tables, the records can be erased from them too depending on the referential integrity rules defined in these relationships. If Access is not able to delete all the records it was supposed to, we will be sent a message advising us that it was not able to as these rules are being infringed on.


Append Query
Append queries are those queries that add whole rows to a table.

The new records are added at the end of the table.

We can insert one row or various rows at the same time, normally getting the data from another table, and so an append query has a source (the table or tables where it gets the data from) and a destiny (the table where we will insert the data). The mechanism is similar to that of a make-table query in so far as we define a selection query which permits us to obtain the data to save, and what does vary is that now we have to indicate into which column we want to save every value.

  • We open a new query in design view.
  • We add the table or tables that we want to extract the data from to store in the destination.
  • Click on Query menu and select the Append query
    The following dialogue box will appear:
  • Choose Table Name where we want to insert the new data to.

    The table will normally be in the same database (Current database option) but we can have the table in another database, but for this we need to select the Another database: option and type the name of the database in the File name: box where the table is to be found. It is easier to look for the database with the Browse... button. click on Browse... and the dialogue box will appear to look for the database.

  • Click on OK button and return to the Query design window.
  • Insert second table field which you append
  • Field: row we indicate the value that we want saved in the destiny field, this value could be a source field, a fixed value, or any valid expression.
  • Appned To: row we indicate the destination field, i.e in which field in the destiny table we want to leave the value defined in this column.
Note: If we have an unique index defined (without duplicates) or Primary key and we try to assign a value that already exists in the table we will also receive an error message.

If the destination table is related to another, the referential integrity rules will be followed.

   Table of Content
Database Object
String Function
Mathematical Function
Date Function
Data Type
Field Properties
Table
Query
Form
Report
ASCII Chart
       
   
© 2008, krishnakumar.com.np. All rights reserved
.