Results 1 to 2 of 2
  1. #1
    asearle is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2010
    Posts
    24

    Parameterised IN (SELECT ...

    Hi everyone,

    I have a query which is reduced by a "IN (SELECT ..." clause entered as a filter on a specific column.



    This works fine but what I would like to do now is add a parameter to the SELECT clause. For example ...

    IN ("SELECT myPersNo FROM tbl_Personnel WHERE Dept_No=" & Forms!frm_Dept!Dept_No )

    As soon as I do this the filter stops working because (I assume) it is handling the SELECT clause as a string.

    I have a work-round (adding the table tbl_Dept to my query) but I'm very interested to know whether "IN (SELECT ..." clauses (when used as filters) can incorporate variable parameters?

    Any help with this would be gratefully received.

    Regards,
    Alan

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    If this is just a query (not in VBA code), does this work?

    IN (SELECT myPersNo FROM tbl_Personnel WHERE Dept_No = Forms!frm_Dept!Dept_No)
    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. Select MAX ( ) +1
    By marco in forum Access
    Replies: 2
    Last Post: 05-05-2010, 03:51 PM
  2. Select value from a list box
    By Hidenite in forum Queries
    Replies: 8
    Last Post: 01-29-2010, 11:31 AM
  3. Field Select
    By RaptureReady in forum Forms
    Replies: 1
    Last Post: 01-28-2010, 08:29 PM
  4. SELECT returns more than one row
    By 83dons in forum Queries
    Replies: 1
    Last Post: 01-13-2010, 11:28 AM
  5. SELECT FUNCTION help please
    By scott munkirs in forum Queries
    Replies: 0
    Last Post: 10-17-2006, 07:44 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