The information in this article applies to:
Advanced: Requires expert coding, interoperability, and multiuser skills. SYMPTOMSWhen you run a parameter query in Visual Basic for Applications, you may receive the following error message.
CAUSEYou receive the error message if you do not set the values of all the parameters in the parameter query in Visual Basic for Applications. MORE INFORMATIONMicrosoft provides programming examples for illustration only, without warranty
either expressed or implied, including, but not limited to, the implied warranties of
merchantability and/or fitness for a particular purpose. This article assumes that you
are familiar with the programming language being demonstrated and the tools used to
create and debug procedures. Microsoft support professionals 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 needs. If you have limited
programming experience, you may want to contact a Microsoft Certified Solution Provider
or the Microsoft fee-based consulting line at (800) 936-5200. For more information about
Microsoft Certified Solution Providers, please see the following page on the World Wide Web:
http://www.microsoft.com/mcsp/For more information about the support options available from Microsoft, please see the following page on the World Wide Web: http://www.microsoft.com/support/supportnet/overview/overview.aspNOTE: The sample code in this article uses Microsoft Data Access Objects. For this code to run properly, you need to reference the Microsoft DAO 3.6 Object Library. This section contains an example of the syntax you use to set the values of a parameter, the sample code to create a query to set the values of a parameter, and the sample code to create a function to set the values of a parameter in parameter queries. NOTE: You have to explicitly assign the parameter in DAO; you do not have to explicitly assign the parameter with the DoCmd.OpenQuery. The reason for this is that DAO uses low-level operations that give you more flexibility (that is, you can assign a variable to a parameter rather than a form's reference) but you have to do the housekeeping that Access does behind the scenes with DoCmd actions. On the other hand, the DoCmd actions operate at a higher level than DAO. When executing a DoCmd action, Microsoft Access makes some assumptions about what to do with parameters--you don't have any flexibility in making them accept a different value. Syntax to Set the Value of a ParameterTo set the value of a parameter that references a form, use the following syntax.
In the example, the definition variable, the exclamation point (!), and the
parameter, which is enclosed in brackets (( )), are to the left of the equal sign (=). Note that if the form name or control name in a form reference contains spaces, it is usually enclosed in brackets. Do not include the brackets if you are setting the value of the form reference parameter. However, do include the brackets if you are referencing the form listed to the right of the equal sign.
Code to Create a Query to Set the Value of a ParameterTo create a query that prompts you to enter the date when you run the query, create a module and enter the following code: NOTE: If you have more than one parameter in the query, add a line
similar to the last line in the code for each parameter.
Sample Function to Set the Value of a ParameterThe following example uses the Orders table from the sample database Northwind.mdb.To create a function that sets the value of a parameter in a parameter query, follow these steps:
REFERENCESFor more information about setting the values of a parameter, click Microsoft Access Help on the
Help menu, type parameter queries, creating in the Office Assistant or
the Answer Wizard, and then click Search to view the topics
returned. Additional query words: expected supplied prb
Keywords : kberrmsg kbprg kbdta PgmObj QryParm |
Last Reviewed: September 17, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |