Is this select statement executed on the SQL server or the client?

F

Fincastle

The form "Open Names" is unbound
It contains a listbox I want to populate with all lastnames starting with A
The letter A is sent to the function below.
When the Listbox is popluated is the filtering taking place on the SQL
server and it is only sending the "A"s to the client OR
is the entire table coming to the client to be filtered?

If it is happening on the client then if I write a spNamesA, spNameB,
spNamesC etc. how to feed it to the listbox.

Thanks



Private Function OpenSearch(Letter As String)
On Error GoTo Err_Command397_Click
Dim SQLSource As String

SQLSource = "SELECT TblNames.LastName, TblNames.FirstName, TblNames.SSN FROM
TblNames WHERE TblNames.LastName LIKE N'" & Letter & "%' ORDER BY
TblNames.LastName, TblNames.FirstName;"

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Open "
DoCmd.OpenForm stDocName, , , stLinkCriteria

[Form_Open ].List5.RowSource = SQLSource


Exit_Command397_Click:
Exit Function

Err_Command397_Click:
MsgBox Err.Description
Resume Exit_Command397_Click
End Function
 
J

John Vinson

When the Listbox is popluated is the filtering taking place on the SQL
server and it is only sending the "A"s to the client OR
is the entire table coming to the client to be filtered?

If there's an index on the field in the server, it's being done on the
server. Access (despite claims to the contrary) will NOT download the
entire table and process it locally, unless you give it no other
choice.

However... there are two errors in the query as written. You can't use
a passthrough query as the rowsource for a listbox, so the query needs
to be in JET format using * rather than % as the wildcard; and it
looks like an extra letter N sneaked in:

SQLSource = "SELECT TblNames.LastName, TblNames.FirstName,
TblNames.SSN
FROM TblNames
WHERE TblNames.LastName LIKE '" & Letter & "*'
ORDER BY TblNames.LastName, TblNames.FirstName;"

Also... is the name of the Form that you're opening really "Open "?
That's what your code seems to indicate!

John W. Vinson[MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top