Solved

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

Posted on 2004-08-19
3
471 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Familiarize people with the process of utilizing SQL Server functions 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 Ac…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

939 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now