Date Parameters In Microsoft Query Wizard



I have been researching how to do this with queries I have that have date parameters that need to be changed each time a report is ran and at first it seemed like using Microsoft Query in Excel would be the best option. This would use the '?' Instead of the dates themselves and allow for adding parameters. So, to select old records with a query, I can put a parameter in my original query, replacing the date. The Parameter is enclosed in square brackets.

MS-Access / Getting Started

The Simple Query Wizard does a great deal of the work of creating a queryfor you. It's most useful when you want to use fields from different tablesand when you want a query that summarizes your data.

The Simple Query Wizard gives you the option of creating either a summary(totals) query or a detail query. A detail query lists every record that meetsyour criteria. A summary query (also called a totals query) performs calculationson your data to summarize it. You can create a summary query if the fields you choose for the query include both of the following:

Microsoft
  • A field with values
  • A field with repetitions or a field with dates, used to group the values

A summary query gives you the option of totaling (summing), averaging,counting the number of values in a field, or finding the minimum or maximumvalue in a field. A summary query creates new calculated fields thatyou can use in other queries or in reports.

If you have a field that lists the amount spentand a field that lists the dates on which the money was spent, the SimpleQuery Wizard creates a summary query for you that sums the amount spent by date.

Ready to give the Simple Query Wizard a spin? Just follow these steps to usethe wizard to create a query:

  1. Display the Create tab on the Ribbon and click the Query Wizard button.
  2. Select Simple Query Wizard from the New Query dialog box and click OK.
    Access displays the first window of the Simple Query Wizard.
  3. Use the Tables/Queries list box to choose the first table or query that you want to use fields from.
    Many queries are based on tables, but you also have the option ofbasing a query on another query. For instance, maybe you already createda query to select sales data from only the year 2003. Now, withoutmodifying the original query, you want to create a query that lists 2003sales by state, or limits the analysis to just a few salespeople.
    When you select a table or query, fields from that object appear in the Available Fields list box.
  4. Move the fields you want to use in the query from the Available Fieldslist to the Selected Fields list by double-clicking a field name (or byselecting the field name and then clicking the > button).
  5. If you're using fields from more than one table or query, repeat Steps2 and 3 to add fields from the additional tables or queries to theSelected Fields list and then click Next.
    From this point on, the windows you see depend upon the types of fieldsand the type of query (detail or summary) you choose.
  6. Choose the type of query you want: Detail or Summary. Depending onyour selection, do one of the following:
    • If you choose a summary query, click the Summary Options button.
    • f you choose a detail query, click Next and jump to Step 9.
    The Summary Options window displays, where you tell the wizard how to summarize each field.
  7. Choose how to summarize your data and click OK to close theSummary Options dialog box. Then click Next to see the next window of the wizard.
    Use the check boxes to indicate the new fields you want Access to create.For example, if you want to add all the values in the Qty field (to calculatehow many of each item have been sold), click the Sum check box in the row for the Qty field.
    Don't overlook the Count check box(es) that may appear in thiswindow - selecting a Count check box tells the wizard to create afield that counts the records within each grouping.
  8. If the fields being summarized can be grouped by a Time/Date field,choose the time interval the records should be grouped by and click Next.
    You will not see this window if your data does not contain a Time/Date field.
    For example, if you choose to include the Order Date field in the queryand to sum the Qty field, you can group by month to see how many ofeach item you sold in each month. You can choose to display total checkamounts by the following options: Day, Month, Quarter, or Year. TheUnique Day/Time option groups records by each unique date and time;if your data includes times, each record with the same date and time isgrouped together. If your data only includes a date without the time,each record from the same day is grouped together (which is the same as the Day option).
  9. Type a name for the query in the box at the top of the window.
    Choose from these options:
    • Open the Query to View Information: This option shows you the query in Datasheet view.
    • Modify the Query Design: This option shows you the query in Design view.
    • Display Help on Working With the Query: Click this check box if you want to see the help screen that covers working with a query.
  10. Click Finish to view the query.
    If you chose the Open the Query to View Information option, you see thequery in Datasheet view. If you chose the Modify the Query Design option, you see your resulting query datasheet.

Microsoft Query Wizard Excel

You can edit the query created by the Simple Query Wizard using Design view, (about which there's lots more in the rest of this tutorial).

Microsoft Query Wizard

The Simple Query Wizard doesn't allow you to include criteria to choose which records you want to include in the query datasheet. If you want toinclude criteria in your query, open the query created by the wizard in Design view and add the criteria. (Details of Design view appear throughout this tutorial.)

Query Wizard Access

In this tutorial: