I am trying to use a form data to modify a query and store it as a recordset.
I have it working properly just opening the query, but I cannot seem to get the QueryDef parameters working the way I would like. (The Me.Territory,Me .State, and Me.Brand is the form data).
I get the error "Item not found in this collection." Currently.
The code that doesn't work:
I have it working properly just opening the query, but I cannot seem to get the QueryDef parameters working the way I would like. (The Me.Territory,Me .State, and Me.Brand is the form data).
I get the error "Item not found in this collection." Currently.
The code that doesn't work:
Code:
'create the recordset
Set db = CurrentDb()
Set qdf = db.QueryDefs(stDocName)
'Query Parameters
qdf.Parameters("Region") = Me.Territory
qdf.Parameters("State") = Me.State
qdf.Parameters("Brand") = Me.Brand
Set rs = qdf.OpenRecordset()
If rs.RecordCount = 0 Then Exit Sub
Comment