G
Guest
Is there a way to invoke a parameter query from VBA where variables are sent
as the parameters so it won't show the pop-ups asking for them?
as the parameters so it won't show the pop-ups asking for them?
Orlando said:Thank you all for your answers.
I guess I missed one point in my original post.
The parameter query is also an action query (Make-Table Query). I was able
to enter the parameter, but then I didn't know how to run it. Finally I was
able to get the SQL code out of the querydef and replace the parameter with a
variable. This works, but I still want to know how you can run the query
using the querydef object.
This is what I have:
Set Db = CurrentDb
Set qdf = Db.QueryDefs("qryMyQuery")
strSQL = Replace(Trim(qdf.Sql), "[Parameter?]", strVariable)
DoCmd.RunSQL strSQL
Orlando said:Thank you all for your answers.
I guess I missed one point in my original post.
The parameter query is also an action query (Make-Table Query). I was able
to enter the parameter, but then I didn't know how to run it. Finally I
was
able to get the SQL code out of the querydef and replace the parameter
with a
variable. This works, but I still want to know how you can run the query
using the querydef object.
This is what I have:
Set Db = CurrentDb
Set qdf = Db.QueryDefs("qryMyQuery")
strSQL = Replace(Trim(qdf.Sql), "[Parameter?]", strVariable)
DoCmd.RunSQL strSQL
Is there a way to invoke a parameter query from VBA where
variables are sent as the parameters so it won't show the pop-ups
asking for them?
Thank you all for your answers.
I guess I missed one point in my original post.
The parameter query is also an action query (Make-Table Query). I was able
to enter the parameter, but then I didn't know how to run it. Finally I was
able to get the SQL code out of the querydef and replace the parameter with a
variable. This works, but I still want to know how you can run the query
using the querydef object.
This is what I have:
Set Db = CurrentDb
Set qdf = Db.QueryDefs("qryMyQuery")
strSQL = Replace(Trim(qdf.Sql), "[Parameter?]", strVariable)
DoCmd.RunSQL strSQL
--
Orlando
Joan Wild said:
- Show quoted text -
Two ways: Direct Reference or Parameter Collection
Direct Reference:
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim qdf As DAO.QueryDef
Set db = CurrentDb()
Set qdf = db.QueryDefs("Query1")
qdf![Forms!form1!Text1] = [Forms]![form1]![Text1]
qdf.Execute "Query1"
Parameters Collection:
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim prm As Parameter
Set db = CurrentDb
Set qdf = db.QueryDefs("Query1")
For Each prm In qdf.Parameters
prm.Value = Eval(prm.Name)
Next prm
qdf.Execute "Query1"
--
--Roger Carlson
MS Access MVP
Access Database Samples:www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
Thank you all for your answers.I guess I missed one point in my original post.
The parameter query is also an action query (Make-Table Query). I was able
to enter the parameter, but then I didn't know how to run it. Finally I
was
able to get the SQL code out of the querydef and replace the parameter
with a
variable. This works, but I still want to know how you can run the query
using the querydef object.This is what I have:Set Db = CurrentDb
Set qdf = Db.QueryDefs("qryMyQuery")
strSQL = Replace(Trim(qdf.Sql), "[Parameter?]", strVariable)
DoCmd.RunSQL strSQL
Seehttp://www.mvps.org/access/queries/qry0013.htm
http://www.mvps.org/access/queries/qry0003.htm
--
Joan Wild
Microsoft Access MVP
Is there a way to invoke a parameter query from VBA where variables are
sent
as the parameters so it won't show the pop-ups asking for them?
- Show quoted text -
S u s i e D B A said:you should be using Access Data Projects if you're at this point
it's much much much simpler
Docmd.RunSql "MySproc 1,12,'Aaron'"
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.