Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Understanding parameter queries

From: Access 2010: Queries in Depth

Video: Understanding parameter queries

So far, we've seen lots of ways that you the query designer can control the records displayed in the query data sheet. But what if we wanted to setup a framework and allow the end user of our query to supply some of the input? For instance, what if we have a question that asks which employees live in the state of blank or blank is supplied by the end user at runtime? Access allows us to answer these kinds of questions with a parameter query. A parameter query allows you to create a query framework that will request some little bit of additional information every time it's viewed. This saves you from creating a separate query for each and every possible question that you or your end users might have.

Understanding parameter queries

So far, we've seen lots of ways that you the query designer can control the records displayed in the query data sheet. But what if we wanted to setup a framework and allow the end user of our query to supply some of the input? For instance, what if we have a question that asks which employees live in the state of blank or blank is supplied by the end user at runtime? Access allows us to answer these kinds of questions with a parameter query. A parameter query allows you to create a query framework that will request some little bit of additional information every time it's viewed. This saves you from creating a separate query for each and every possible question that you or your end users might have.

Let's go into Access and we will create a query that answers this specific question. We will go up to the Create tab and we'll create a new query in Design view. Now, we are interested in finding out information about our employees and the states they are from. So we will take the Employees table, double-click on it, and the States table, double-click on that. Go ahead and close the Show Table window. I am going to rearrange these a little, so I can see all of the fields and we will add a couple of fields to our query. Double-click on FirstName, double-click on LastName, and we'll double-click on StateName.

Now, in previous movies we saw how we can use the criteria field to specify a specific state. For instance, if I was interested in all the employees that lived in state of Arizona, I could type-in Arizona for the criteria, run this uery, and Access returns the 3 employees that live in Arizona. So go ahead and switch back in our Design view and we will change this into a parameter query. A parameter query uses the square bracket and then a bit of text to prompt the user for what kind of information you're looking for. So for instance, I could write open square bracket, enter state, closing square bracket.

When I run this query we will get a box that pops up that prompts the user to enter the state. This time we will type in California. We have one employee that lives in the state of California. If I switch back to Design view and then run this query again, we could type in a different state. This time Florida. Go ahead and say OK and you can see that we have 6 employees that live in the state of Florida. Let's go back into Design view. Now, we can combine this parameter request with some of the logical operators that we saw earlier.

For instance, if I was interested in two different States, I could say (nter first state and on the or line I could say enter second state. Make sure you have enclosed everything in square brackets. When I run this query, Access will prompt me for one state. Let's say New York and it will prompt me for a second state. Let's say Vermont. Now, I can see that I have 7 employees that either live in New York or Vermont. Let's go back into Design view. I will go ahead and get rid of the second state and I will expand this field a little.

You could also use the Or statement on the single line. Enter first state or enter second state. This will give us the same query that we just ran. Let's go ahead and clear this out and I will just get rid of everything here. We can also use the Like operator and we see this in the earlier movie, but we can use this with a parameter request to request something like all the states that begin with the letter A. We will start with like. We will input our parameter request.

Enter state letter. End that with a square bracket. Now, we need to join this to our asterisk wildcard and we will see this "concatenates" ampersand use a little bit later, but here we will just type the ampersand and then asterisk. So this says we want to look for all the states that start with a letter and they're joined with any letters after that. Let's go ahead and run this. Access will prompt us to enter a letter. I am going to enter A and we will say OK, and Access will give us all of the results for the states that begin with the letter A. Parameter queries are a powerful way to add interactivity to your database.

By providing a basic framework, you can create a single query that serves up answers to lots of different questions. Letting your end users define their own questions can be a really powerful tool. It adds flexibility to your database and it could be a way to streamline your work or providing some level of future proofing. Parameter variables will allow your queries to serve up answers to questions that you didn't even consider during the design process and I think that's really cool. The Enter Parameter Values dialog box isn't the only way for your end users to define the variables in a query. In the next movie we will look at how you can use the data entry forms and buttons to hook into the variables we've just seen.

Show transcript

This video is part of

Image for Access 2010: Queries in Depth
Access 2010: Queries in Depth

46 video lessons · 14085 viewers

Adam Wilbert
Author

 
Expand all | Collapse all
  1. 9m 9s
    1. Welcome
      1m 10s
    2. Using the exercise files
      41s
    3. Introducing the database
      4m 29s
    4. Previewing the course
      2m 49s
  2. 17m 17s
    1. Understanding queries
      3m 31s
    2. Following naming conventions and best practices
      2m 56s
    3. Using the Query Wizard
      5m 21s
    4. Exploring the design interface
      5m 29s
  3. 26m 39s
    1. Defining criteria
      5m 40s
    2. Understanding comparison operators
      3m 19s
    3. Defining the column headers
      2m 49s
    4. Exploring the property sheet
      7m 32s
    5. Printing query results
      2m 41s
    6. Working with joins
      4m 38s
  4. 14m 14s
    1. Understanding parameter queries
      4m 27s
    2. Obtaining parameters from forms
      5m 17s
    3. Creating a combo box
      4m 30s
  5. 23m 24s
    1. Understanding the Totals field
      5m 31s
    2. Creating aggregate calculations
      3m 31s
    3. Exploring the Expression Builder interface
      4m 28s
    4. Using mathematical operators
      5m 46s
    5. Applying text functions
      4m 8s
  6. 24m 23s
    1. Understanding dates as serial numbers
      2m 42s
    2. Specifying a range of dates or times
      3m 47s
    3. Formatting dates
      4m 31s
    4. Using other Date/Time functions
      3m 47s
    5. Defining today's date
      2m 41s
    6. Calculating time intervals
      6m 55s
  7. 20m 9s
    1. Introducing the conditional IIf function
      2m 57s
    2. Creating an IIf function
      7m 31s
    3. Nesting IIf functions
      4m 57s
    4. Using the Switch function
      4m 44s
  8. 20m 41s
    1. Understanding the reporting tool
      2m 13s
    2. Building the form
      6m 57s
    3. Building the query
      5m 4s
    4. Building the report
      3m 30s
    5. Finalizing the reporting tool
      2m 57s
  9. 25m 37s
    1. Finding duplicate records
      2m 17s
    2. Identifying unmatched records
      2m 29s
    3. Creating crosstab results
      2m 57s
    4. Creating backups
      1m 29s
    5. Creating update queries
      3m 22s
    6. Making, deleting, and appending records
      5m 36s
    7. Uniting tables
      3m 16s
    8. Embedding SQL code in queries
      4m 11s
  10. 1m 0s
    1. Next Steps
      1m 0s

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ .

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now Already a member? Log in

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Access 2010: Queries in Depth.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member ?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferences from the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Learn more, save more. Upgrade today!

Get our Annual Premium Membership at our best savings yet.

Upgrade to our Annual Premium Membership today and get even more value from your lynda.com subscription:

“In a way, I feel like you are rooting for me. Like you are really invested in my experience, and want me to get as much out of these courses as possible this is the best place to start on your journey to learning new material.”— Nadine H.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.