How to Create Access Queries
Microsoft Access queries are used to sort, organize and manipulate data in Access databases. Queries can be used to create reports, show parts of objects in forms, and create and update tables. Queries range from a simple selects to more complex joins. Microsoft Access provides you with three different options to create a query, all which allow you to edit the query later. You can use a wizard, write an SQL statement or use design view.
Instructions
-
-
1
Open an existing Microsoft Access database or create a new one.
To create a new database, open Microsoft Access, go to "File -- New," click "Blank Database," and name your database. -
2
Click on "Queries" under Objects in project window. This window lists all query options and any existing queries.
You must create at least one table in order for queries to work properly. Unless your query is creating a table, go to "Tables" under Objects and use the "Create table by using wizard" or "Create table by entering data" option to quickly create tables. -
-
3
Create a new query in Design view by clicking "Create query in Design view."
Select which tables and/or queries you want to use in your query. Press "Add" for each one you wish to add.
If you're using multiple tables and/or queries, join the objects by field. For instance, if Table1 has a Name field and Query1 also has the same field, draw a line from one field to the other. Right click the line to change the join properties, or to delete the join. This isn't required, but will yield the results you want easier and faster.
Drag the fields you wish to use to the "Field" boxes in the Design view window. Choose how you want data sorted, whether you want the field actually shown in the query itself, and add in additional criteria. Additional criteria filters out data. For instance, if you only want a certain name to appear in your query, type the name surrounded by quotation marks in the Criteria box.
Change the type of query by clicking the "Type of Query" button to the left of the red exclamation point. This allows you to create Select, Crosstab, Make-Table, Update, Delete and Append queries.
Press the red exclamation point in the toolbar to run your query. If you need to edit further, press pencil/ruler design view button on the toolbar. Close the query when finished, and enter a name for your query. Don't use spaces in the name. Instead, use an underscore or no space between words. -
4
Create a new query using the wizard by clicking "Create query using wizard." You can also access other wizards by clicking "New" at the top of the project window. Choose the tables and queries you wish to use, and select the fields you want to add to your query. Press "Next."
Select a name for your query. You don't have to accept the default. Decide whether to run your query, or modify the design. Modify will open the query in Design view. Click "Finish." -
5
Create SQL queries. These queries will require you to understand SQL statements. Create a blank query in Design view. To create a blank query, close the field selection window when Design view opens.
Click "SQL" at the top left of the screen. Type your statement in the box. Field, query and table names are case-sensitive.
Press the "Save" button, which looks like a small blue floppy disk, to save your query.
-
1
Tips & Warnings
Edit a query at any time by selecting the query, and clicking "Design" in the project window. You can also add tables and queries to your query even after creation.
Create a backup copy of your database before testing any Delete, Append or Update queries. These edit the data in your tables. Alternately, you can create copies of your tables within your databases before running a query that modifies data.