Solved

Setting the Rowsource of a List Box with a Stored Procedure and Parameter from code

Posted on 2004-08-19
3
476 Views
Last Modified: 2008-03-17
I am using  an Access 2003 Project (.ADP). On a form I have an Unbound List Box (lstEmployee) and a unbound text box (txtSearch).  I want the user to be able type in a partial name in the txtSearch field and then in the AfterUpdate Event procedure needs to fire off code to set the rowsource to the stored procedure (sp_GetEmployee) along with the parameter from the txtSearch textbox

CREATE PROCEDURE sp_GetEmployee
@Employee varchar(25)
AS
SELECT *
FROM vwEmployeeList
WHERE EmployeeName Like @Employee
GO
0
Comment
Question by:jfrenzley
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 50

Accepted Solution

by:
Steve Bink earned 125 total points
ID: 11842694
Wouldn't it be easier to remove the SP and set the row source directly?

Private Sub txtSearch_AfterUpdate()

lstEmployee.RowSource = "SELECT * FROM vwEmployeeList WHERE EmployeeName Like '%" & txtSearch & "%'"
lstEmployee.Requery

End Sub
0
 

Author Comment

by:jfrenzley
ID: 11843287
Well my understanding is that stored procedures run faster and are ran on the server side.  Network bandwith is an issue.  By using a view directly will it just send the result set or does it send everything?

0
 
LVL 50

Expert Comment

by:Steve Bink
ID: 11871114
Any query you send to a remote server will always return only the result set.  The key is to limit the results to what you need.  For example, opening a table in datasheet view is the same as running the query:

SELECT * FROM MyTable

Running this as an SP on the server, you will not likely see any appreciable speed increase, and the returned results will be the same no matter which method you use.  In fact, using an SP or pass-through query for something simple like this may actually INCREASE the execution time by a small margin.  SPs and pass-through queries are generally meant for those programming items that will have A LOT of execution overhead, or are so complicated that it takes a beast of a machine to wade through.  If there is one universal piece of programming advice, it must be the mantra of KISS...Keep It Simple (Insert Preferred Slur Here).
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question