Link to home
Start Free TrialLog in
Avatar of rrhandle8
rrhandle8Flag for United States of America

asked on

VBA Run-Time error '3265' parameter query

I get the error on this line:  qdf.Parameters("[episode]").Value = 10
Error: Item not found in this collection.


Sub test()
    
    Dim dbs As DAO.Database
    Dim qdf As DAO.QueryDef
    Dim prm As DAO.Parameter
    Dim rst As DAO.Recordset
    
    Set qdf = CurrentDb.QueryDefs("ValueMemo Query2")
    
    qdf.Parameters("[episode]").Value = 10
    
    Set rst = qdf.OpenRecordset
    
    Do While Not rst.EOF
        Debug.Print rst("ValueMemo")
    Loop
    
End Sub

Open in new window

Avatar of IrogSinta
IrogSinta
Flag of United States of America image

Do you actually have a parameter named episode in your query or is that a fieldname?

Ron
Avatar of rrhandle8

ASKER

SELECT *
FROM FieldValue AS f, [session] AS s
WHERE f.objectid = s.sessionid and s.isnote=0 and  s.providerid = 2 and s.episodeid = ["episode"]
ORDER BY s.StartDateTime DESC;
ASKER CERTIFIED SOLUTION
Avatar of IrogSinta
IrogSinta
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
revise your query like this

PARAMETERS episode Long;
SELECT *
 FROM FieldValue AS f, [session] AS s
 WHERE f.objectid = s.sessionid and s.isnote=0 and  s.providerid = 2 and s.episodeid = [episode]
 ORDER BY s.StartDateTime DESC;