I am trying to use the following code to open up a recordset of a query from code behind a window. stDocName is the name of the query. The problem is the criteria I am using in the query is not a field value from the form but a variable I set in the code. Is this possible? I don't know how to reference it variable in the criteria field of the query. Any thoughts?
Dim qdf As DAO.QueryDef
Dim prm As DAO.Parameter
Set qdf = db.QueryDefs(stDocName)
For Each prm In qdf.Parameters
prm.Value = Eval(prm.Name)
Next prm
Set rs = qdf.OpenRecordset
Dim qdf As DAO.QueryDef
Dim prm As DAO.Parameter
Set qdf = db.QueryDefs(stDocName)
For Each prm In qdf.Parameters
prm.Value = Eval(prm.Name)
Next prm
Set rs = qdf.OpenRecordset