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:
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[BL_GetCont] 
	-- Add the parameters for the stored procedure here
@Cont varchar(30),
@Date varchar (10)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

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

Open in new window

JFBrubakerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
0
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:

<DEFAULT>
<NULL>

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

Peanut Butter
Lunchmeat
Tuna Salad
<DEFAULT>
<NULL>

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


Parameter.JPG
0
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
0
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.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.