• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 640
  • Last Modified:

SQL2005 stored procedure query parameter default value drop down list

I have a stored procedure that is run by a query in a MS Access ADP. When I run the query, I get a combobox where I can enter the parameter value. If I click on the drop down I have the option to select <DEFAULT> or <NULL>. I know I can add a default value. What I would like to do is have 2 or 3 options in the drop down for the user to select from. Is this possible? I've been searching for an answer, but maybe I'm not phrasing my searches correctly.

For the parameter @Cont, I'd like to have 2 or 3 options in the drop down box for the user to select. This would save me from having to have 2 or 3 separate queries.

Here's my stored procedure:
	-- Add the parameters for the stored procedure here
@Cont varchar(30),
@Date varchar (10)
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.

    -- Insert statements for procedure here
	WHERE 	[Cont] LIKE '%' + @Cont + '%'
			AND [BDAT] > = @Date

Open in new window

  • 2
1 Solution
Guy Hengel [angelIII / a3]Billing EngineerCommented:
JFBrubakerAuthor Commented:
I'll read through it more carefully, but I don't think that is what I'm looking for. I don't need a query based on list of parameters. I only need one parameter for the query, but I want to choose what that parameter is. When I run the procedure, I get a combo box where I can manually type in the parameter I want to use for the query. Right now when you click on the combo box, you can select:


What I would like to do is populate the combo box with additional parameters to select from. For example:

Peanut Butter
Tuna Salad

So if the user clicks on 'Peanut Butter', the stored procedure is run using 'Peanut Butter' as the parameter.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
so, the question is: how to populate the dropdown?
you should check the dropdown's properties, there are some that allow you to set how to fill the dropdown part from a query, or using a list of hard-coded values
Vadim RappCommented:
1. When you run a stored procedure directly, you have no control on what Access will offer you to specify as parameter. If you want the control, you'll have to create a form, and create your own combobox, and only that will allow you to specify the items you want. Besides the combobox, the form will probably have some button that will run the stored procedure and pass it the parameter taken from the currently selected value of the combobox.

2 Further, the best practice is to show the results of the query also in a form, or datasheet, or report, rather than open it directly.

3. Stored procedures are the least preferred way to work in Access; if stored procedure is a mere single SELECT statement, like yours, it makes sense to use that sql directly, without the stored procedure.

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now