G
Gibson
I'm trying to use the following code to run a query that will return only
the records where Field1 in the query is equal to strField1(a variable I
define). When I run the code I receive a Item Not Found In Collection error
at the line where I Set the prm. to Field1. I do not have anything in the
criteria of Field1 in qry1 because I don't know what to put in there. I
can't reference a variable set behind the form there, can I? I've never
used this type of code before and am obviously in the dark. Thanks for any
suggestions.
Dim qdf As DAO.QueryDef
Dim prm As DAO.Parameter
Set qdf = db.QueryDefs(qry1)
Set prm = qdf.Parameters![Field1]
'Set parameter value
prm = strField1
'Execute QueryDef to produce a recordset
Set rs = qdf.OpenRecordset
the records where Field1 in the query is equal to strField1(a variable I
define). When I run the code I receive a Item Not Found In Collection error
at the line where I Set the prm. to Field1. I do not have anything in the
criteria of Field1 in qry1 because I don't know what to put in there. I
can't reference a variable set behind the form there, can I? I've never
used this type of code before and am obviously in the dark. Thanks for any
suggestions.
Dim qdf As DAO.QueryDef
Dim prm As DAO.Parameter
Set qdf = db.QueryDefs(qry1)
Set prm = qdf.Parameters![Field1]
'Set parameter value
prm = strField1
'Execute QueryDef to produce a recordset
Set rs = qdf.OpenRecordset