IIf([PlanType] Like "*Open*","Yes","No")
will be true for BN Open. BE Open-J
On the Create tab, in the Other group, click Query Wizard.
In the New Query dialog box, double-click Find Unmatched Query Wizard.
On the first page of the wizard, select the table that has unmatched records, and then click Next. For example, if you want to see a list of Northwind 2007 products that have never been sold, select the Products table.
On the second page, select the table that is related, and then click Next. To follow the example, select the Order Details table.
On the third page, select the fields that relate the tables, click < = >, and then click Next. You can choose only one field from each table. To follow the example, select ID from the Products table and Product ID from the Order Details table. Verify that the correct fields are matched by reviewing the text in the Matching fields box.
Note that the ID and the Product ID fields may already be selected because of existing relationships built in to the template.
On the fourth page, double-click the fields that you want to see from the first table, and then click Next. To follow the example, select the ID and Product Name fields.
On the fifth page, you can choose to view the results or to modify the design of your query. In this example, click View the results. Accept the suggested name for the query, and then click Finish.
You may want to modify your query's design to add other criteria, to change the sort order, or to add or to remove fields. For information about modifying a Find Unmatched query, read the following section; or, for more general information about creating and modifying queries, see the links in the See Also section.
Create and modify a Find Unmatched Query to compare by more than one field
- On the Create tab, in the Other group, click Query Wizard.
- In the New Query dialog box, double-click Find Unmatched Query Wizard.
- On the first page of the wizard, select the table that has unmatched records, and then click Next. For example, if you want to see a list of Northwind 2007 products that have never been sold, select the Products table.
- On the second page, select the table that is related, and then click Next. To follow the example, select the Order Details table.
- On the third page, select the fields that relate the tables, click < = >, and then click Next. You can choose only one field from each table. To follow the example, select ID from the Products table and Product ID from the Order Details table. Verify that the correct fields are matched by reviewing the text in the Matching fields box. You can join the remaining fields after you have completed the wizard.Note that the ID and the Product ID fields may already be selected because of existing relationships built in to the template.
- On the fourth page, double-click the fields that you want to see from the first table, and then click Next. To follow the example, select the ID and Product Name fields.
- On the fifth page, click Modify the design, and then click Finish.The query opens in Design view.
- In the query design grid, note that the two tables are joined on the fields (in this example, ID and Product ID) that you specified on the third page of the wizard. Create a join for each remaining pair of related fields by dragging them from the first table (the table that has unmatched records) to the second table. For this example, drag the List Price field from the Products table to the Unit Price field from the Order Details table.
- Double-click a join (the line connecting the fields) to display the Join Properties dialog box. For each join, choose the option that includes all the records from the Products table, and then click OK.In the query design grid, note that each join now has an arrow at one end.1. When you create the join between the List Price and Unit Price fields, it restricts output from both tables. Only those records with matching data in the fields in both tables are included in the query results.2. After you edit the join properties, the join only restricts the table that the arrow points to. All records in the table that the arrow points from are included in the query results.NOTE: Make sure that all of the arrows on the joins are pointing in the same direction.
- For the table that has related records (in this example, the Order Details table), double-click each field that is joined to the first table, except for the field that you chose on the third page of the wizard (in this case, the Product ID field). For each of these fields, clear the check box in the Show row, and type Is Null in the Criteria row.
- Optionally, add criteria to the other query fields, or create calculated fields that are based on values from the first table.
- On the Design tab, in the Results group, click Run.The query returns the names of products that are not part of any existing orders.
Create your own query to find unmatched records
- On the Create tab, in the Other group, click Query Design.
- In the Show Table dialog box, double-click the table that has unmatched records, and then double-click the table that has related records.
- Close the Show Table dialog box.
- In the query design grid, the two tables should have lines, called joins, connecting them by their related fields. If the joins are not there, create them by dragging each related field from the first table (the table that has unmtached records) to the second table (the table that has related records).
- Double-click a join to open the Join Properties dialog box. For each join, choose option 2, and then click OK.In the query design grid, the joins change so that they have arrows at one end.NOTE: Make sure that all of the joins are pointing in the same direction. The query will not run if the joins point in different directions, and may not run if any join is not an arrow. The joins should point away from the table that has unmtached records.
- In the table that has unmatched records, double-click the fields that you want the query to return.Optionally, enter criteria for any of these fields, or create calculated fields.
- For the table that has related records, double-click each field that is joined to the first table. For each of these fields, clear the box in the Show row, and type Is Null in the Criteria row.
- On the Design tab, in the Results group, click Run.