I am using the following code to set up a recordset of a query. The query SQL is below. The problem is when I try to set a variable to the value of Field3 an error tells me InvLine is not in the collection. The first two fields,Field1 and Field2 are there. In the locals window when I run the code it indicates there are only 2 items in the collection, the first two fields. Can anyone see what I'm doing wrong with this code?
Set qdef2 = db.QueryDefs("qry2")
Set parm2 = qdef2.Parameters(0)
'Set parameter value
parm2 = strField1
'Execute QueryDef to produce a recordset of qry2 which
Set rsAII2 = qdef.OpenRecordset
SELECT TblInvDet.Field1, TblInvDet.Field2, TblInvDet.Field3
FROM TblInvDet
ORDER BY Val([TblInvDet.Field2]), TblInvDet.Field3;
Set qdef2 = db.QueryDefs("qry2")
Set parm2 = qdef2.Parameters(0)
'Set parameter value
parm2 = strField1
'Execute QueryDef to produce a recordset of qry2 which
Set rsAII2 = qdef.OpenRecordset
SELECT TblInvDet.Field1, TblInvDet.Field2, TblInvDet.Field3
FROM TblInvDet
ORDER BY Val([TblInvDet.Field2]), TblInvDet.Field3;