ACC2002: Default Parameter Is Automatically Applied to Stored Procedures (279821)
The information in this article applies to:
This article was previously published under Q279821 Moderate: Requires basic macro, coding, and interoperability skills.
This article applies only to a Microsoft Access project (.adp).
SYMPTOMS
When you use the Default keyword with a parameterized stored procedure, you are not prompted to provide a value for the parameter. Instead, the stored procedure automatically runs using the default value for the parameter.
RESOLUTION
To ensure that you are prompted with default values, use a SQL function instead of a stored procedure. To create a function with default values, follow these steps:
- Open the sample project NorthwindCS.adp.
- On the Insert menu, click Query.
- In the New Query dialog box, click Design In-Line Function, and then click OK.
- Click Close to close the Add Table dialog box without adding a table.
- On the View menu, click SQL View.
- Add the following Transact SQL in the SQL Text Editor:
CREATE FUNCTION fnCustOrders
(@EnterCustomerID varchar(5)='WOLZA')
RETURNS TABLE
AS
RETURN (SELECT dbo.Customers.*
FROM dbo.Customers
WHERE (CustomerID = @EnterCustomerID))
- On the File menu, click Save.
- Save the function as fnCustOrders, and then close it.
- Run the fnCustOrders function from the Database window.
- In the Enter Parameter Value dialog box, click the arrow, and then click <DEFAULT>.
- Click OK.
Note that the function returns the record where the CustomerID field equals "WOLZA", because that is the default value.
STATUS
This behavior is by design.
Modification Type: | Major | Last Reviewed: | 11/6/2003 |
---|
Keywords: | KbClientServer kbprb KB279821 |
---|
|