18.11.2014 Views

Microsoft Office

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Using <strong>Microsoft</strong> Query with External Database Files 33<br />

n<br />

n<br />

Item: A text field that specifies the budget item. Each budget category has different budget items.<br />

For example, the Compensation category includes the following items: Benefits, Bonuses,<br />

Commissions, Conferences, Entertainment, Payroll Taxes, Salaries, and Training.<br />

Month: A text field that specifies the month (abbreviated as Jan, Feb, and so on).<br />

n Year: A numeric field that stores the year (either 2005 or 2006).<br />

n Budget: A numeric field that stores the budgeted amount.<br />

n Actual: A numeric field that stores the actual amount spent.<br />

n Variance: A numeric field that stores the difference between the Budget and Actual.<br />

The task<br />

The objective of this exercise is to create a report that shows the first quarter 2006 (January through March)<br />

Compensation expenditures of the Training Department in the North American Division. In other words,<br />

the query will extract records that meet all of the following criteria:<br />

n<br />

n<br />

n<br />

n<br />

The Division is N. America.<br />

The Department is Training.<br />

The Category is Compensation.<br />

The Month is Jan, Feb, or Mar.<br />

n The Year is 2006.<br />

Using Query to get the data<br />

One approach to this task is to import the entire Access file into a worksheet using the method described<br />

earlier in this chapter (see “Importing Access Tables”). When the table is imported, you can filter it to display<br />

only the rows that meet the specified criteria. This approach works because this particular table isn’t<br />

very large. However, in some cases, the number of records in the table may exceed the number of rows in a<br />

worksheet. The advantage of using Query is that it imports only the data that’s required. And, once you’ve<br />

imported the data, you can refresh the query at any time to bring in updated data.<br />

Selecting a data source<br />

Begin with an empty worksheet. Choose Data ➪ Get External Data ➪ From Other Sources ➪ From<br />

<strong>Microsoft</strong> Query, which displays the Choose Data Source dialog box, shown in Figure 33.4. This dialog box<br />

contains three tabs:<br />

n<br />

n<br />

n<br />

Databases: Lists the data sources that are known to Query — this tab may be empty, depending<br />

on which data sources are defined on your system.<br />

Queries: Contains a list of stored queries. Again, this tab may or may not be empty.<br />

OLAP Cubes: Lists OLAP databases available for query.<br />

Your system may have some data sources already defined. If so, they appear in the list on the Databases tab.<br />

To set up a new data source, use the option. For this example, choose and click OK. The Create New Data Source dialog box, which has four parts, appears (see<br />

Figure 33.5):<br />

579

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!