Setup: Displaying the SQL Query Window
To build your first query, you need to start by opening the SQL query window in Microsoft Access 2000, which allows you to manually send queries to the database. Follow these steps:
Start Microsoft Access 2000.
In the opening dialog box, you specify whether you want to create a new database or open an existing one (see Figure 2).
Figure 2 Select an existing database or create a new one.
In the last tutorial, we created a database called visualtutorial. To use that database again, click the radio button labeled Open an Existing File and select the database name in the list box. The database was located in the folder c:\inetpub\wwwroot\informit, so highlight the database c:\inetpub\wwwroot\visualtutorial.
Click OK to display the Access opening window (see Figure 3).
Figure 3 Microsoft Access 2000 opening window.
You should see an icon for your GuestBook table in the window. However, this time we're not going to design a table; instead, we're going to design a SQL query.
In the Objects column, click the Queries buttonit's just below the Tables button. The right pane of the window displays some query options (see Figure 4).
Figure 4 Query options are displayed in the right pane of the window.
Double-click the icon labeled Create Query in Design View. Access opens a query design window and the Show Table dialog box (see Figure 5).
Figure 5 Starting a new query.
Click the Close button to exit the Show Table dialog box. The query design window remains. You use this window when building a query graphically, but since we're building this query manually we won't need it.
Figure 6 Use this window to design queries graphically.
Figure 7 Selecting the view to use.
To build a query manually, we want to work in SQL view, so select the SQL View item from the drop-down list on the View button. Notice that the resulting SQL query window in Figure 8 looks quite different from the one shown earlier in Figure 6.
Figure 8 Use this window to design queries manually.
You use the Show Table dialog box to select the tables you want to use in your SQL queries when graphically building a query. We've only created one table (GuestBook), so only one entry is displayed in the list box. And since we're actually going to build the query manually this time, we don't need to use the Show Table dialog box.
At last, we're ready to type some queries!