queiries

  • Thread starter Thread starter Darren Spooner
  • Start date Start date
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
 
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.
 
Back
Top