IT tutorials
 
Office
 

Microsoft Accesss 2010 : Enhancing the Queries That You Build - Creating and Running Action Queries (part 1) - Creating and Running Update Queries

- How To Install Windows Server 2012 On VirtualBox
- How To Bypass Torrent Connection Blocking By Your ISP
- How To Install Actual Facebook App On Kindle Fire
11/16/2014 8:01:12 PM

With Action queries, you can easily modify data without writing any code. In fact, using Action queries is often a more efficient method of modifying data than using code. Four types of Action queries are available: Update, Delete, Append, and Make Table. You use Update queries to modify data in a table, Delete queries to remove records from a table, Append queries to add records to an existing table, and Make Table queries to create an entirely new table. The sections that follow explain these query types and their appropriate uses.

Creating and Running Update Queries

You use Update queries to modify all records or any records that meet specific criteria. You can use an Update query to modify the data in one field or several fields (or even tables) at one time. For example, you could create a query that increases the salary of everyone in California by 10%. As mentioned previously, using Action queries, including Update queries, is usually more efficient than performing the same task with Visual Basic for Applications (VBA) code, so you can consider Update queries a respectable way to modify table data.

Build an Update Query

To build an Update query, follow these steps:

1.
Select Query Design from the Queries group on the Create tab of the Ribbon. The Show Table dialog box appears.

2.
In the Show Table dialog box, select the tables or queries that will participate in the Update query and click Add. Click Close when you’re ready to continue.

3.
To let Access know you’re building an Update query, select Update from the Query Type group on the Design tab of the Ribbon.

4.
Add to the query fields that either you will use for criteria or Access will update as a result of the query. In Figure 1, Ship State/Province is included on the query grid because we will use it as a criterion for the update. Shipping Fee is included because it’s the field that Access will update.

Figure 1. An Update query that increases DefaultRate for all clients in California.

5.
Add any further criteria, if you want. In Figure 1, the criterion for Ship State/Province is CA.

6.
Add the appropriate Update expression. The example illustrated in Figure 1 increases DefaultRate by 10%.

7.
Click Run in the Results group on the Design tab of the Ribbon. The message box shown in Figure 2 appears. Click Yes to continue. Access updates all records that meet the selected criteria.

Figure 2. The confirmation message you see when you run an Update query.


You should name Access Update queries with the prefix qupd. In fact, you should give each type of Action query a prefix indicating what type of query it is. This makes your application easier to maintain, and makes your code more readable, and renders your code self-documenting. Table 1 lists all the commonly accepted prefixes for Action queries.

Table 1. Naming Prefixes for Action Queries
Type of QueryPrefixExample
UpdatequpdqupdDefaultRate
DeleteqdelqdelOldTimeCards
AppendqappqappArchiveTimeCards
Make TableqmakqmakTempSales

Access displays each type of Action query in the Navigation Pane with a distinctive icon.


Access stores all queries as Structured Query Language (SQL) statements. You can display the SQL for a query by selecting SQL View from the View drop-down list on the toolbar. The SQL behind an Access Update query looks like this:

UPDATE tblClients SET tblClients._
DefaultRate = [DefaultRate]*1.1
WHERE (((tblClients.StateProvince)="CA"));

You cannot reverse the actions taken by an Update query or by any Action queries. You must therefore exercise extreme caution when running any Action query.

 
Others
 
- Microsoft Accesss 2010 : Enhancing the Queries That You Build - Creating and Running Parameter Queries
- Microsoft Accesss 2010 : Enhancing the Queries That You Build - Getting Help from the Expression Builder
- Microsoft Accesss 2010 : Enhancing the Queries That You Build - Creating Calculated Fields
- Using OneNote with Other Office 2010 Applications : Entering Outlook Information (Email, Meeting, Contact, Task) on a Page
- Using OneNote with Other Office 2010 Applications : Entering Meeting Details from Outlook in a Note
- Using OneNote with Other Office 2010 Applications : Opening a Page in Word, Creating an Outlook Task in OneNote
- Microsoft Visio 2013 : A Visual Orientation to a Visual Product - Panning and zooming in Visio
- Microsoft Visio 2013 : A Visual Orientation to a Visual Product - Managing the Shapes window
- Microsoft Visio 2013 : A Visual Orientation to a Visual Product - Exploring the drawing window
- Microsoft Excel 2010 : Working with Graphics - Moving an Object, Resizing an Object , Deleting an Object
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
programming4us programming4us
 
Popular tags
 
Video Tutorail Microsoft Access Microsoft Excel Microsoft OneNote Microsoft PowerPoint Microsoft Project Microsoft Visio Microsoft Word Active Directory Biztalk Exchange Server Microsoft LynC Server Microsoft Dynamic Sharepoint Sql Server Windows Server 2008 Windows Server 2012 Windows 7 Windows 8 Adobe Indesign Adobe Flash Professional Dreamweaver Adobe Illustrator Adobe After Effects Adobe Photoshop Adobe Fireworks Adobe Flash Catalyst Corel Painter X CorelDRAW X5 CorelDraw 10 QuarkXPress 8 windows Phone 7 windows Phone 8 BlackBerry Android Ipad Iphone iOS