Per JohnP:
Quote:
I have a query qry2 which is based on query qry1. Both qry1 and qry2
are defined in Access. I would like to use parameters for both
queries. I indicate below a simple verson of the queries as they
appear in Access:
qry1:
SELECT * FROM tblX
WHERE (tblX.[fldName]) Is Not Null);
qry2:
INSERT INTO tblY ( fld1, fld2, fld3)
SELECT qry1.[fld1], qry1.[fld2], qry1.[fld3] FROM qry1;"
Is there a simple way to incorporate qry1 into qry2 so that I can use
DoCmd.RunSQL to run qry2? |
Yes, by using the UI's query builder screens, specifying the
parameters via Query | Parameters and saving the resulting
queries.
If you run Qry2 "by hand", it will then prompt for the parms.
If you run qry2 in VBA, you will:
-----------------------------------
Dim myRS as DAO.Recordset
Dim myQury As DAO.QueryDef
Set myQuery = CurrentDB.QueryDefs("qry2"
With myQuery
.Parameters("theParm1") = Whatever
.Parameters("theParm2") = Whatever
set myRS = .OpenRecordset(dbOpenSnapshot, dbForwardonly)
End With
-----------------------------------
--
PeteCresswell