In MS Access, we can create a query to retrieve the information or fetch the data from a table or even from multiple tables. We can also use the query as the basis of a data access page, a form or a report. The following article will show you how to create the simple queries in MS Access and how we can apply sorting and criteria to our queries. The most common type of query is a select query provided in MS Access and this is used to retrieve the data from one or more than one table. Here we will discuss how to create a Select Query through the MS Access Wizard. The following are the steps that will take you through the wizard to create a certain query and show you how to create a query for the retrieval of information regarding customers and the orders from the sample database that is included within MS Access.
Step1: Start the MS Access and then open up the sample database. After that, On the View menu you can easily point to Database Objects, and then click on Queries.
Step2: Click on the Insert menu over there and in the insert menu you have to click on Query. A new query box will pop up and in that y dialog box, click on Simple Query Wizard and then click on OK.
Step3: Once you have the Simple Query Wizard dialog box, click on the Customers table in Tables/Queries list, and after that Double-click on each of the following fields to add them to Selected Fields box: Contact Name, CustomerID, Contact Title, and Company Name.
Step4: Further on the same page of Simple Query Wizard, you have to click on Orders table in Tables/Queries list. Click twice to add all fields from Orders table to the Selected Fields box.
Step5: Finally click on the finish button. This Simple Query Wizard will construct the query for you and will displays results in Datasheet view.
Lets us see how to create the Select Query from Design View.
Step1: Start the Microsoft Access and Open the .mdb extension sample database. On View menu you can point to the Database Objects and then click on Queries.
Step2: In Database Window, double-click on Create Query in the Design View then in the Show Table dialog box you have to click on Customers, and after that click on Add link.
Step3: Click on close to close Show Table dialog box. In Customers table field list that is located in top half of query design window, double-click to add these fields: Contact Name, CustomerID, Contact Title, and Company Name.
Step4: In Orders table field list that is located in top half of the query design window, double-click to add the field is equivalent of selecting all fields from a particular table. Now at last, go onto the File menu and then click Save. Type qryCustomerOrders for name of the query, then on the Query menu, click on Run to view results of the query.