Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2004-08-19
3
Medium Priority
?
490 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 51

Accepted Solution

by:
Steve Bink earned 375 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 51

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

661 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