remember that all this is worthwhile when the back end table is large and the returning data is quite small, otherwise doing it locally in access will be as fast (or as slow...)
and also, note that you can call this sub (and use the query afterwards) for anything that runs on sqlserver, be it scalar, table (recordset) or nonquery (things that will run on the server internally) functions, storeprocs etc....





by: ErezMorPosted on 2009-11-08 at 10:15:19ID: 25771251
there quite a few approaches to solve this, here's one:
create a passthrough query (it doesnt matter what it is, it's just to hold all connection information so you dont need to enter it every time)
now add a public sub in code:
qrySQLPass Through") df.SQL = strSQL
Public Sub ChangePTquerySQL(strSQL As String)
Dim qdf As DAO.QueryDef
Set qdf = DBEngine(0)(0).QueryDefs("
q
Set qdf = Nothing
End Sub
now you can call this sub every time with the full sql passthrough syntax, and then set the result to your needs. so in your example you use the after update event of adoptValue and cboLocation in the Forms!frmAdoptionList:
if isNull(cboLocation)=False And IsNull(adoptValue)=False Then
ChangePTquerySQL "Exec dbo.sp_sa_lstAdoption '" & cboLocation & "'," & adoptValue & ";"
then, if lstAdoption rowsource is set to "qrySQLPassThrough" then will do the trick
Me.lstAdoption.Requery
good luck