K
Kelii
I want to pass parameters to a sub (embedded?) query using VBA. Here
are the intricacies:
1. The "primary" query is constructed in VBA (using variable strSQL)
and utilized in a "db.OpenRecordset (strSQL, dbOpenDynaset)" procedure
2. The "primary" query that builds the dataset is simple and has no
form references:
e.g., Select qrySQ4.Field1, tblTable1.Field1, etc...
3. The "sub" query that is referenced in the primary query has several
form references:
e.g., SELECT tblTable2.Field1
FROM tblTable2
WHERE tblTable2.Field1 < Forms!ParentForm!Object
When executed, the db.OpenRecordset (strSQL, dbOpenDynaset) command
fails and requests additional parameters. I've identified the source
of the issue: query parameters cannot be resolved using DAO in the
db.OpenRecordset command. My first attempt at a work around is to set
the "sub" query parameters using DAO; e.g.,
Set qdQueryDefName = db.QueryDefs (qrySourceSubQuery)
qdQueryDefName.Parameters("Parameter1").Value = Forms!ParentForm!
Object
'More code
Set recROPFrom = db.OpenRecordset(strSQL, dbOpenDynaset)
'More code
End Sub
This has had no impact. The VBA OpenRecordset still fails and requests
parameters.
QUESTION: Does anyone know if the sub query parameters can be set
using VBA. If so, when those parameters are set, do they then carry
over to the "Primary" query, when the primary query calls the "sub"
queries recordset. If all of this is possible, is there sample
syntax / website / helpfile that I've missed in my research? If the
parameters cannot be effectively passed, what is a typical work around
for this type of issue.
Thanks in advance.
Best,
Kelii
Note: this a new branch of a discussion from comp.databases.ms-access
group. If you've followed that discussion and see this post, I
apologize.
are the intricacies:
1. The "primary" query is constructed in VBA (using variable strSQL)
and utilized in a "db.OpenRecordset (strSQL, dbOpenDynaset)" procedure
2. The "primary" query that builds the dataset is simple and has no
form references:
e.g., Select qrySQ4.Field1, tblTable1.Field1, etc...
3. The "sub" query that is referenced in the primary query has several
form references:
e.g., SELECT tblTable2.Field1
FROM tblTable2
WHERE tblTable2.Field1 < Forms!ParentForm!Object
When executed, the db.OpenRecordset (strSQL, dbOpenDynaset) command
fails and requests additional parameters. I've identified the source
of the issue: query parameters cannot be resolved using DAO in the
db.OpenRecordset command. My first attempt at a work around is to set
the "sub" query parameters using DAO; e.g.,
Set qdQueryDefName = db.QueryDefs (qrySourceSubQuery)
qdQueryDefName.Parameters("Parameter1").Value = Forms!ParentForm!
Object
'More code
Set recROPFrom = db.OpenRecordset(strSQL, dbOpenDynaset)
'More code
End Sub
This has had no impact. The VBA OpenRecordset still fails and requests
parameters.
QUESTION: Does anyone know if the sub query parameters can be set
using VBA. If so, when those parameters are set, do they then carry
over to the "Primary" query, when the primary query calls the "sub"
queries recordset. If all of this is possible, is there sample
syntax / website / helpfile that I've missed in my research? If the
parameters cannot be effectively passed, what is a typical work around
for this type of issue.
Thanks in advance.
Best,
Kelii
Note: this a new branch of a discussion from comp.databases.ms-access
group. If you've followed that discussion and see this post, I
apologize.