Query Criteria, Part 3: Prompting for input by using a parameter

Query Criteria, Part 3: Prompting for input by using a parameter In part 2 of this series, we considered using LIKE and ...

Query Criteria, Part 3: Prompting for input by using a parameter

In part 2 of this series, we considered using LIKE and wildcards in query criteria to find inexact matches. Good stuff – but what if you could get the query to apply criteria that are supplied when it is run? What if you could make a query ask for input? Good news! You can make a query ask for input, and it's actually very easy.

All you do is use a question enclosed in square brackets in place of a normal criterion. When someone runs the query, the first thing it does is present a dialog box displaying the question you used. Let's have a look at the design of the query that produced that Customer's last name? dialog box.

 Prompting for input by using a parameter   Query Criteria, Part 3: Prompting for input by using a parameter

The query returns all the data from the Customers table, but only those records where LastName matches the user's answer to this:

 Prompting for input by using a parameter   Query Criteria, Part 3: Prompting for input by using a parameter

That gets the job done, but there are things you can do to improve the query's usability. For one, you can declare your parameters so Access will provide a sensible error message if someone inputs the wrong type of data (for example, someone enters text when a number is required).

To declare a parameter:

  1. Open the query in Design view and copy the parameter question to the Clipboard, including the brackets (select the parameter question and press Ctrl+C).

  2. On the Query Tools | Design tab, in the Show/Hide group, click Parameters.

  3. In the Query Parameters dialog box, paste the copied parameter into the Parameter column, and then set the data type using the drop-down list in the Data Type column.

 Prompting for input by using a parameter   Query Criteria, Part 3: Prompting for input by using a parameter

If you really want to go all-out, you can use a form to collect the input. A form opens up all kinds of possibilities, such as sharing input parameters among a set of queries or providing a date-picker to input a date/time parameter. For more information, see Use parameters in queries, forms, and reports.

Disclaimer : All images and content that you find here are believed to be in the "public domain". We do not intend to violate legitimate intellectual property, artistic rights or copyright. If you are the legitimate owner of one of the images and content posted on this site, and do not want to be displayed or if you need an appropriate credit, please contact us and we will immediately do whatever is needed by deleting or giving credit to the content displayed.

COMMENTS

Name

Google Aррѕ,1,lainnya,7522,Microsoft Access,1,Microsoft Excel,59,Microsoft Office,13,Microsoft Office 2003,4,Microsoft Office 2007,1,Microsoft Outlook,1,Microsoft Word,71,Mісrоѕоft Office Training,1,Mісrоѕоft Offісе 365,2,Office 2007,3,Power Map,1,PowerPoint,14,Windows Accessibility Options,1,
ltr
item
Microsoft Office Online: Query Criteria, Part 3: Prompting for input by using a parameter
Query Criteria, Part 3: Prompting for input by using a parameter
https://support.content.office.net/en-us/media/bc356f86-1775-407b-8972-923b01b92657.png
Microsoft Office Online
https://promisestoread.blogspot.com/2018/05/query-criteria-part-3-prompting-for.html
https://promisestoread.blogspot.com/
https://promisestoread.blogspot.com/
https://promisestoread.blogspot.com/2018/05/query-criteria-part-3-prompting-for.html
true
593202333244584315
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share. STEP 2: Click the link you shared to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy