queiries

D

Darren Spooner

i have a queiry that has a parameter. and in VBA i want to the parameter so
the queiry does not ask me. how do i do that
 
J

John Vinson

i have a queiry that has a parameter. and in VBA i want to the parameter so
the queiry does not ask me. how do i do that

One useful technique is as follows:

Dim db As DAO.Database
Dim qd As DAO.Querydef
Dim prm As Parameter
Dim rs As DAO.Recordset
Set db = CurrentDb
Set qd = db.Querydefs("yourqueryname")
For Each prm In qd.Parameters
prm.Value = Eval(prm.Name)
Next prm
Set rs = qd.OpenRecordset


Thus if the parameter is a form reference, the string
[Forms]![SomeFormName]![SomeControl] will be evaluated to return the
value in that control, and that value will be assigned to the
parameter's value.
 

Ask a Question

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.

Ask a Question

Top