Microsoft KB Archive/304252

= ACC2000: How to Create a Combo Box That Is Based on a Parameterized Stored Procedure =

Article ID: 304252

Article Last Modified on 6/28/2004

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q304252



Moderate: Requires basic macro, coding, and interoperability skills.

This article applies only to a Microsoft Access project (.adp).



SUMMARY
In a Microsoft Access project (ADP), you can use a parameterized stored procedure as the row source of a combo box on a form. This article gives you an example of how to pass a parameter to the stored procedure that you are using as the row source.



MORE INFORMATION
 Open the sample project NorthwindCS.adp. Click Stored Procedures under Objects, and then click New.  In the Design window of the new stored procedure, replace the existing text with the following Transact-SQL: Create Procedure MyProcedure @text1 varchar(15) AS SELECT CustomerID, CompanyName FROM Customers WHERE city = @text1 ORDER BY CompanyName  Save the stored procedure. Click Forms under Objects, click New, and then click OK to create a new, unbound form. Add a combo box to the new form, and then set the following properties:

Name: cboCompany

ColumnCount: 2

ColumnWidths: 0&quot;;1.5&quot;

BoundColumn: 1

</li> Add a text box to the form, and name it txtParam.</li>  Add the following code to the AfterUpdate event of the txtParam text box: 'The following line will pass the value in the text box to the stored procedure. Me!cboCompany.RowSource = &quot;EXEC MyProcedure '&quot; & Me!txtParam.Value & &quot;'&quot; Me!cboCompany.Requery </li> Save the form, and then open the form in Form view.</li> Type London in the text box.</li> Press the TAB key to move to the combo box.

Note that only customers from London appear in the list.</li></ol>

Additional query words: parameter

Keywords: kbhowto kbinfo KB304252

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.