How to Display Access Query
- 1). Open Access and create a new database table with the following sample data. Type the top row of this data as the table's column headers:
BookTitle,SaleDate ,SaleAmount
The Walking Man,1/1/2009,$6.01
The Walking Man,1/3/2009,$5.98
Hello Dilly,1/5/2009,$2.98
Hello Dilly,1/6/2009,$1.98
Press "Control"-"S" to save the table. Name it "SalesOfBooks." - 2). Create a new query for the table, beginning with selecting it in the navigation window at the left of the screen. Press "Create" on Access' toolbar, followed by "Query Design." If you're using Access 2003, press "Objects," then "New," then "Query" to create the query.
- 3). Double-click the "SalesOfBooks" item in the "Show Table" dialog box, then press "Close" on that box. Drag any item or collection of items, except for the "*," from the small "SalesOfBooks" window, onto the query grid below that window.
- 4). Right-click the query's tab (which reads "Query1" or similar) and select "DataSheet View." Notice that Access displays the results of the query.
- 5). Begin displaying the query in another way, starting with right-clicking the tab of the last query's results. Choose "SQL View" to display the SQL (Structured Query Language) view of the query you created with the query grid.
- 6). Select the text in the SQL statement that follows the "SELECT" keyword. Notice that this text is the name of one or more of the fields from your sample table (i.e., SaleDate, SaleAmount, BookTitle).
Type a "*" in place of the selected text, then redisplay the query results using the instructions in Step 4. Notice that all fields of the table are now displayed since the "*" represents all fields. - 7). Press "Control"-"S" to save the query and database. Name the query "Query1" when prompted. Close the query by right-clicking its tab, then selecting "Close" from the context menu.
- 8). Select the "Query1" item in the navigation window, then create a new report whose data will come from that query: select "Create," followed by "Report" on the Access toolbar. Notice that Access has displayed the query in another way--through a report. (Access 2003 users: Create the report by pressing "Objects," then "Report," then "New.")
Verify that the report's data came from the query by double-clicking the "Query1" in the navigation pane. Compare each item in the query's result with the corresponding item in the report. - 9). Right-click "query1" in the navigation pane and select "Design View" to begin another method of displaying an Access query. Right-click the "Query1" tab and select "SQL View" if that view isn't yet displayed.
- 10
Replace the existing SQL with the following statement, which creates a new table whose data will contain the query's results:
SELECT BookTitle as "Title of book" into JustBookTitles
FROM SalesOfBooks; - 11
Run the revised query by pressing the "Run" icon on the Access toolbar. Press "Yes" when the dialog box with the message "You are about to paste 4 rows..." appears. - 12
Double-click the new table, named "JustBookTitles" that's appeared in the navigation window. Notice that the table's only field is the one that you specified in the query.
Source...