I am a newbie at VBA and in need of some help with how best to create a recordset from an existing Access Query that requires 2 Parameters from an open form. This query works fine as an ordinary query but i just can't get it to work using VBA. The 2 fields in the form to be used as parameters are
[CompanyName] and [MthFwd]. I am working with Access 2003 in Win XP. I have Microsoft DAO 3.6 in the references. Thanks in advance for any help.
My code is:
This code gives me an error '3265'
Item not found in this collection
I have tried all kinds of variations in code but no joy so far.
LSteve (L = Learner)
[CompanyName] and [MthFwd]. I am working with Access 2003 in Win XP. I have Microsoft DAO 3.6 in the references. Thanks in advance for any help.
My code is:
Code:
Dim qdf as DAO.Querydef
Dim Rst as DAO.Recordset
Dim Dbs as DAO.Database
Dim sMthFwd, sCompanyName as String
sCompanyName = ([Forms]![ViewIndents by Store]![CompanyName])
sMthFwd = [Forms]![ViewIndents by Store]![IndentOrdDetails Subform]![MthFwd]
set Dbs = CurrentDb()
Set qdf = Dbs.QueryDefs("qryIndentOrdersForEmailing")
qdf.Parameters![CustomerName] = sCompanyName
qdf.Parameters![MthFwd] = sMthFwd
Set Rst = qdf.OpenRecordset()
Item not found in this collection
I have tried all kinds of variations in code but no joy so far.
LSteve (L = Learner)
Comment