You can most certainly change the sql of the pass through query.
eg:
Dim qdfPass As DAO.QueryDef
Dim rst As DAO.Recordset
Set qdfPass = CurrentDb.QueryDefs("MyPass")
qdfPass.SQL = "exec sp_myProc"
qdfPass.Execute
The above is used to send "raw" commands to sql server.
And, if you want to return data, simply go:
qdfPass.SQL = "SELECT field1, field2, field3 " & _
"FROM TABLE1 " & _
"WHERE Condition1 = 1234 " & _
"AND Condition2 = 5678 " & _
"AND Condition3 = 91011;"
Set rst = qdfPass.OpenRecordset
Now, if you looking to do the above for a report, or form, I would actually
create a linked table to the stored view on the server side, and simply use
the "where" clause to open the report.
eg:
dim strWhere as string
strWhere = "Condition1 = 1234 " & _
"AND Condition2 = 5678 " & _
"AND Condition3 = 91011"
docmd.OpenReport "ReportName",acViewPreview,,strWhere
I see little if any benefit to use/build a sql pass-through query here. I
think using a simple where clause is the least amount of work (and I find
performance to that linked view works VERY well, as good as a pass-though
anyway). So, simply bind the report to that linked view on the server. Just
thinking about this, binding the report to the pass-though should also
accept the where clause also
So, the give the "where" clause idea if this is a report. And, if it is
reocrdset processing code, then the above querydef example is just fine
also...
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pleaseNOOSpamKallal@msn.com