Results 1 to 3 of 3
  1. #1
    violeta_barajas is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Apr 2016
    Posts
    13

    Pass a variable to a Pass Through Query


    Hello,

    I have below pass through query object created in MS Access that makes an SELECT from an Oracle table. The issue with this is that when passing the variable from VBA to this query object, error 3265 "item not found in this collection" is generated.

    Here the code in VBA:

    Set myQuery = myDB.QueryDefs("SelectFromUsersQuery")
    myQuery.Parameters("user_id") = Me.[USER_ID] ' The error is generated at this point
    myQuery.Execute
    myQuery.Close

    Here the local pass through query:
    SELECT USERID, FIRST_NAME FROM USERS WHERE USERID = &user_id;

    I intent for Oracle to execute this query and not MS Access. But I need that value from that form.


    Thank you.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    how bout?

    Set myQuery = currentDB.QueryDefs("SelectFromUsersQuery")

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Try

    myQuery.SQL = Replace(myQuery.SQL, "&user_id", Me.[USER_ID] )
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 04-27-2015, 02:40 PM
  2. Replies: 7
    Last Post: 03-11-2015, 12:48 PM
  3. Replies: 2
    Last Post: 12-10-2012, 02:23 PM
  4. Replies: 4
    Last Post: 01-03-2012, 08:11 PM
  5. VBA Pass-through Query with Variable
    By smaumau in forum Programming
    Replies: 0
    Last Post: 12-06-2010, 09:10 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums