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
Klatuu - 19 Jul 2005 17:58 GMT
Dim qdf As DAO.QueryDef
Dim rst as Recordset
Set qdf = db.QueryDefs(qry1)
qdf.Parameters(0) = strField1
set rst = qdf.OpenRecordSet
if Not rst.EOF Then
rst.MoveLast
rst.MoveFirst
End If
> 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
[quoted text clipped - 14 lines]
> 'Execute QueryDef to produce a recordset
> Set rs = qdf.OpenRecordset