Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

ACC2000: How to Use IIf() in Crosstab to Limit Column Headings


View products that this article applies to.

This article was previously published under Q208669
Novice: Requires knowledge of the user interface on single-user computers.

This article applies only to a Microsoft Access database (.mdb).

↑ Back to the top


Summary

You can use the IIf() function to group values under a small number of headings in a crosstab query. This article demonstrates how to group records by country and to count the number of orders placed for each customer.

NOTE: You can see a demonstration of the technique that is used in this article in the sample file Qrysmp00.exe. For information about how to obtain this sample file, please see the following article in the Microsoft Knowledge Base:
207626� ACC2000: Access 2000 Sample Queries Available in Download Center

↑ Back to the top


More information

To use the IIf() function to individually list companies whose names begin with the letter "A," and to group all other companies under the OTHERS column heading, follow these steps:
  1. Start Microsoft Access and open the sample database Northwind.mdb.
  2. Create the following new crosstab query based on the Orders table and the Customers table:
       Query: MyQuery
       ---------------------------------------------------------
       Type: Crosstab query
       Join: Orders.[CustomerID]<->;Customers.[CustomerID]
    
       Field: Country
          Table: Customers
          Total: Group By
          Crosstab: Row Heading
       Field: IIf([CompanyName] Like "A*",[CompanyName],"OTHERS")
          Total: Group By
          Crosstab: Column Heading
       Field: Order ID
          Table: Orders
          Total: Count
          Crosstab: Value
    					
  3. Run the query.

↑ Back to the top


Keywords: KB208669, kbhowto

↑ Back to the top

Article Info
Article ID : 208669
Revision : 3
Created on : 7/15/2004
Published on : 7/15/2004
Exists online : False
Views : 360