Well, I've been searching around the groups for an answer to this one,
and none of the suggestions seems to be working for me. I'm almost
positive that this is a simple fix, but for the life of me I can't
figure out what I'm doing wrong.
I have a form that uses a query as its recordsource; I'll call the
query qryParent.
qryParent is based on 2 nested queries; which is to say qryParent
selects from qryChild2 and qryChild2 selects from qryChild1.
qryChild1 has two parameters: Company_Locatio n and Menu_Price_Date
I am trying to set the parameter for qryChild1 using DAO, then opening
the form which uses qryParent as its recordsource.
The problem is that my code doesn't do anything, Access still prompts
me for the parameters.
Now, before it is suggested, I want to preempt the following:
1. I want to keep the queries generic so that I can use them in future
forms; therefore I am not willing to set the parameters to field
values on the various forms (which could be done)
2. I could write the whole query in SQL (I think) and set the
parameters in the SQL string; however, I would prefer to use the
'parameter setting process' b/c it limits the lines of code in an
already complex procedure
Ok, so here is the code I'm using:
Private Sub Form_Load()
On Error GoTo Error_Handler
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Set db = CurrentDb
Set qdf = db.QueryDefs("q ryChild1")
qdf.Parameters( "Menu_Price_Dat e") = Date
qdf.Parameters( "Company_Locati on") = Me.txtCompanyLo cation
Me.Recordsource = _
qryParent
' ....Code Continues....
Any thoughts or suggestions would be extremely well received.
Thanks,
Kelii
and none of the suggestions seems to be working for me. I'm almost
positive that this is a simple fix, but for the life of me I can't
figure out what I'm doing wrong.
I have a form that uses a query as its recordsource; I'll call the
query qryParent.
qryParent is based on 2 nested queries; which is to say qryParent
selects from qryChild2 and qryChild2 selects from qryChild1.
qryChild1 has two parameters: Company_Locatio n and Menu_Price_Date
I am trying to set the parameter for qryChild1 using DAO, then opening
the form which uses qryParent as its recordsource.
The problem is that my code doesn't do anything, Access still prompts
me for the parameters.
Now, before it is suggested, I want to preempt the following:
1. I want to keep the queries generic so that I can use them in future
forms; therefore I am not willing to set the parameters to field
values on the various forms (which could be done)
2. I could write the whole query in SQL (I think) and set the
parameters in the SQL string; however, I would prefer to use the
'parameter setting process' b/c it limits the lines of code in an
already complex procedure
Ok, so here is the code I'm using:
Private Sub Form_Load()
On Error GoTo Error_Handler
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Set db = CurrentDb
Set qdf = db.QueryDefs("q ryChild1")
qdf.Parameters( "Menu_Price_Dat e") = Date
qdf.Parameters( "Company_Locati on") = Me.txtCompanyLo cation
Me.Recordsource = _
qryParent
' ....Code Continues....
Any thoughts or suggestions would be extremely well received.
Thanks,
Kelii
Comment