Article ID: 210530 - Last Review: June 23, 2005 - Revision: 3.0 ACC2000: How to Create a Parameter In() StatementThis article was previously published under Q210530 Moderate: Requires basic macro, coding, and interoperability skills.
This article applies only to a Microsoft Access database (.mdb). On This PageSUMMARY
This article demonstrates two methods that you can use to pass multiple
values to a query by using a parameter prompt. The first method uses the
Instr() function to parse the parameter values entered when the query is run. The second method describes a way to create a query by using the In() operator with multiple values.
NOTE: You can see a demonstration of the technique that is used in this article in the sample file Qrysmp00.exe. For information about how to obtain this sample file, please see the following article in the Microsoft Knowledge Base: 207626
(http://support.microsoft.com/kb/207626/EN-US/
)
ACC2000: Access 2000 Sample Queries Available in Download Center
NOTE: The sample code in this article uses Microsoft Data Access Objects. For this code to run properly, you must reference the Microsoft DAO 3.6 Object Library. To do so, click References on the Tools menu in the Visual Basic Editor, and make sure that the Microsoft DAO 3.6 Object Library check box is selected.MORE INFORMATIONMethod 1The following method demonstrates how to use the Instr() function to pass multiple values, separated by commas, to a parameter query.CAUTION: If you follow the steps in this example, you modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and follow these steps on a copy of the database.
Method 2The following method uses a query that calls a function and passes it two parameters. The first parameter is the name of a field that exists in the table on which the query is based. The second parameter prompts the user to type a list of values. The function processes the user's entries as the list of multiple parameters for the In() operator.Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. CAUTION: If you follow the steps in this example, you modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and follow these steps on a copy of the database.
IN("A*","BON*","CRATE???") REFERENCESFor more information about the In operator, in the Visual Basic Editor, click Microsoft Visual Basic Help on the Help menu, type in operator example (dao) in the Office Assistant or the Answer Wizard, and then click Search to view the topic.
| Article Translations
|
Back to the top
