How to Use If in a Select Access Query
Access queries let you extract data out of the database by the fields and criteria you specify. The queries can be viewed as questions you ask of your database. The results are displayed in the query datasheet view. When creating the query in the design view, a query expression can be created to get a more customized result. Expressions are functions that you create within the query. The If function can be used in an Access query as an IIf function.
Instructions
-
-
1
Open Access 2010 and select a database. Click the "File" tab and select the "Open" icon. Browse the files and locate the database. Double-click the database to open it.
-
2
Click the "Create" tab and select "Query Design." Add a table to the query by clicking the "Add" button from the Show Table dialog box. Close the dialog box by clicking the "Close" button.
-
-
3
Add a field to the query by double-clicking the table field names. Create an expression by typing the function in the next-available query column. An example of the IIf function could be created with a Class directory database. If the classes have an attendance level of less than 5 students, the class will be retired. Enter the following IIf statement: "IIf([Class_Attendance]<5,"Retire","Do Not Retire"." Notice less than is notated with the "<" symbol.
-
4
Run the query to see the results by clicking the "Run" icon on the ribbon. Review the results in the query datasheet view.
-
1