98.7% Of all customers recommend us, we're so confident about our results we publish all reviews and stats
View Live Stats View ReviewsPrevious article Next article Access articles
How To Use Multiple Parameters In A Microsoft Access Query
Sun 24th July 2011
If you create a parameter query in query design view, you enter criteria data under one or more field headings in the form of text surrounded by square brackets. When the query is then run, a prompt appears displaying this text and an empty text box. The user types data into this box, clicks OK, and this data is passed to the query as the criteria data. If the user runs the query again and enters different data via the prompt, the query will of course show different results.
If you create more than one parameter in separate query fields, then when the query is run the parameter prompts appear in turn for each field criteria. So after you enter the data for the first parameter and click OK, the next parameter prompt appears, and so on, until all parameter data is entered. Once all the parameter data is entered the query finishes running and displays the results.
You can enter parameters into more than one field at a time in different ways in the query design view. You can enter the parameter criteria in different fields, in the same criteria row across the query. If you do this the query will display records which meet the first parameter entered AND the second AND the third and so on. So parameters entered across the same criteria row work like a logical AND. Alternatively you can enter parameter criteria down a column under a particular field. If you do this the query will display records which the first parameter entered OR the second OR the third and so on. So parameters entered down a criteria column under a field work like a logical OR.
You can of course combine this and enter a mix of parameters across one or more criteria row and down one or more criteria column. This can result in a relatively complex way the different criteria are used. However if you remember the rules of AND across the same criteria row and OR down the same criteria column, you can build very effective parameter mixes.
Parameter queries can allow users to enter different types of data into the query such as text or numbers or dates. We'll look now at an example using dates as parameter data.
An interesting use of multiple parameter queries is to use the same parameter criteria more than once in the query design, across the same criteria row. If you do this and run the query, the user enters data only once, and all the fields use this same criteria data. This can be very useful when working for example with dates as parameters. We'll describe an example next.
Say you have an Access table of records which include three date fields. The fields might be "Date Received", "Date Processed" and "Date Completed". You want to create a query which shows which records have dates for all three fields between certain dates. So you create your query and include these three dates. We'll want to use a parameter query which allows the user to specify two dates to give us our dates range. To do this the parameter criteria will look something like "BETWEEN [Enter date1] AND [Enter date2]" without the quote marks. You can type this into the first date criteria, and then copy and paste it into the other two fields without changing any parameter detail.
By the way when you come to copy the criteria from the first date field, you may see that the column containing the criteria is not wide enough to show all the data. You can see all the data by right clicking the criteria cell and choosing zoom. The zoom panel opens with all the criteria data highlighted. You can then copy this data, close the zoom panel, and paste the data into both the other two criteria cells. So now each date field in the query has the same parameter criteria.
Now run the query, enter the first date, then the second date. Then when you click OK both sets of parameter data are applied to all three date fields. The query results show records which fall within the range specified by the two parameter prompts for all three date fields.
Parameter queries are just one of the many useful design features you can work with using Microsoft Access. A really effective way of learning more is to attend a training course and then really boost your Access skills.
Author is a freelance copywriter. For more information on microsoft access training london, please visit https://www.stl-training.co.uk
Original article appears here:
https://www.stl-training.co.uk/article-1813-how-use-multiple-parameters-in-microsoft-access-query.html
London's widest choice in
dates, venues, and prices
Public Schedule:
On-site / Closed company:
TestimonialsMedicspro Ltd
Bookkeeper Josh Barnett Excel Intermediate Jens was incredibly enthusiastic and the facts about 500 functions, 60 can be used in 1 cell is impressive stuff! To be honest the biggest improvement would have to be on directions, it was really confusing on how to even get to the building even with the directions I got via email! The lesson had everything I needed for my job and anything I asked Jens was answered how I wanted. I will be back for the advanced course and hope he is teaching again! Jazwares
Operations Coordinator Anj Nankany Excel Advanced Max is awesome and explains perfectly. Please continue to apply theoretical work to real-life/ work practices, it's super useful. Thanks. Casio Electronics Company Ltd
Andy Brown Excel Intermediate The explanations from Sarah were simple and factfull making it very easy to replicate and solve the tasks and made them very easy to implement into daily routines |
PUBLICATION GUIDELINES