SunQuest
 
       Microsoft Access
  Home arrow Microsoft Access arrow Page 2 - Creating and Using Action Queries
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Actuate Whitepapers 
VeriSign Whitepapers 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
MICROSOFT ACCESS

Creating and Using Action Queries
By: Jayaram Krishnaswamy
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 6
    2007-01-16

    Table of Contents:
  • Creating and Using Action Queries
  • Creating an Employee Addresses Table Using a Select Query
  • Create an Address Table from the Select Query
  • Create an Append Query
  • Appending the Records

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Creating and Using Action Queries - Creating an Employee Addresses Table Using a Select Query


    (Page 2 of 5 )

    We can start with a Select query. After making the selections and applying conditions for filtering, if any, we can convert it into a make table query. The following design view of a Select query shows the six fields that are to be included in the table, named Address. We will use an expression to create a field which has the full name in one column using two of the fields from this query.

    Here a table called Address will be created from the data in the Employees table as shown. We will be choosing the columns needed for the Address table. We will also add a column which has the First Name together with the Last Name, for which we need to build an expression. In an empty Field row in the above window, right click to bring up the context-sensitive menu. Choose Build... to bring up the Expression Builder as shown, expand the Tables node, highlight the First name, and click on Value in the highlighted area. This adds the code [Employees] ! [FirstName] to the expression as shown.

    Now complete by adding a space between First Name and Last Name, and then add the Last name in a way that is similar to the way you added the First Name. Use the available buttons on the Expression builder as shown.

    When you click on the OK button on the Expression Builder the concatenated string is added to your design view of the query as shown. The SQL view of the query is now as shown in the next paragraph. Save the query as EmployeeAddress.

    SELECT Employees.EmployeeID, Employees.LastName, Employees.FirstName, 
    Employees.Address, Employees.City, Employees.PostalCode, 
    Employees.Country, [Employees]![FirstName] & " " & 
    [Employees]![LastName] AS Expr1
    FROM Employees;
    

    When you run this query by double-clicking the EmployeeAddress query icon you will see the following output. As you can see the last column shows the concatenated expression.

    Go back to the design of the query and refine the query so that you do not choose the First Name and Last Name as shown in the SQL View (they are not included in the select list). In some versions of MS Access, when you open the query in SQL View, you may not be able to change it to the Query Design view.

    SELECT Employees!FirstName & " " & Employees!LastName AS Emp_name,  
    Employees.Address, Employees.City, Employees.PostalCode,  
    Employees.Country 
    FROM Employees;
    

    The column in blue is the 'Full Name' created by the Expression Builder. You replaced Expr1 with "Emp_name." The output of this query is now as shown in the next picture. You have rearranged everything just as you needed.

    More Microsoft Access Articles
    More By Jayaram Krishnaswamy


       · This is really written for those beginners learning to use MS Access as a first step...
     

    MICROSOFT ACCESS ARTICLES

    - Linking SQL Express 2005 Tables to MS Access...
    - Working with Access Projects in Access 2007
    - Exploring Access 2007
    - Working with Stored Procedures in an MS Acce...
    - Creating and Using Action Queries
    - Creating Data Access Pages with Charts using...
    - Advanced Ideas using VBA
    - VBA Details
    - Updating Records in MS Access
    - Using ADO`s Record Object with URLs
    - Exporting XML from MS Access 2003
    - Importing XML into MS Access 2003
    - On Using Pass-through Queries in MS Access
    - Distributed Queries in MS Access
    - Configuring a Linked Microsoft Access Server...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway