XMan said:
I'm looking for a way to improve the app performance by moving my queries
with filtering to SQL2K server.
Is there a way to bind a form or report to a dynamic query in a stored
procedure? TIA.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I believe the result set of an SP is read-only. Therefore, it would be
better to use a View as the RecordSource of a form on which you intend
to edit data. Since reports are not editable you could use the SP.
Are you using an .mdb Access file or an .adp? Which version of Access?
If .mdb file you can use a QueryDef as the form's/report's RecordSource.
When the form/report opens use the Open event to set up the QueryDef's
..SQL property. E.g.:
Private Sub Report_Open(Cancel As Integer)
' The query "QueryName" is the report's RecordSource
' The form "frmCriteria" has the SP's criteria
' stored in the TextBox "txtCriteria"
Dim db as DAO.Database
Dim qd As DAO.QueryDef
Set db = Currentdb
Set qd = db.QueryDefs("QueryName")
qd.SQL = "exec usp_ProcedureName " & Forms!frmCriteria!txtCriteria
qd.Close
End Sub
In .adp files you can upt the EXEC statement in the RecordSource (both
form's & reports). Just change it as needed in the form's/report's Open
event procedure. E.g.:
Private Sub Report_Open(Cancel As Integer)
Me.RecordSource = "EXEC usp_ProcedureName " & _
Forms!frmCriteria!txtCriteria
End Sub
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv
iQA/AwUBQIWwNYechKqOuFEgEQJn0wCfRg0Bnup7R3GIgHfNy5aOYpGikp4An0Mn
AmFZfYvc8t3BsAmAyGZV9OqU
=CpyM
-----END PGP SIGNATURE-----