Results 1 to 3 of 3
  1. #1
    jjsande1492 is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    May 2018
    Posts
    38

    Query based on filtered records using recordset?

    Hi there.

    I am trying to construct a query that will pull all records from a table where the Part_ID is in the list of filtered records in my subform. I want to join another table to pull in the SKU and Part_Number of the Part_ID. I thought I could accomplish this via recordsetclone, but it is only pulling the records based on the first Part_ID it sees. How can I better accomplish what I am trying to do?

    My current construction:
    Code:
    strSQL = "SELECT tbl_BillOfMaterials.*, tbl_Parts.SKU, tbl_Parts.Part_Number FROM tbl_BillOfMaterials INNER JOIN tbl_Parts ON tbl_BillOfMaterials.Part_ID = tbl_Parts.Part_ID WHERE (((tbl_Parts.Part_ID) IN (" & rs![Part_ID] & ")))"
    Cheers,


    jj

  2. #2
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,741
    Don't think that approach will work. And FYI, your IN clause only contains one value, making it same as a WHERE = clause.
    I wouldn't take a recordsource clone approach.

    The linking field between the main form and the subform is Part_ID, right?
    If the recordsource for the subform is a named query, use that in your join and use the Part_ID from the main form to add your WHERE clause.
    You COULD set the Part_ID to a tempvar in the Main Form_Current event, then it would be available for use the query's WHERE.
    If the recordsource for the subform is a query string, just use that string to make a named query, and go with above.
    Last edited by davegri; 06-26-2018 at 01:45 PM. Reason: options

  3. #3
    jjsande1492 is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    May 2018
    Posts
    38
    Thanks, davegri. Based on your response and my continued search on the web, it doesn't seem like what I am trying to do is possible. I will have to loop through the recordset instead.

    Thanks for your help.

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

Similar Threads

  1. Filtered Records Wont Stay Filtered
    By ortizimo in forum Access
    Replies: 4
    Last Post: 11-29-2017, 07:08 PM
  2. Replies: 4
    Last Post: 01-17-2016, 02:52 PM
  3. simple filtered recordset question
    By RonL in forum Access
    Replies: 3
    Last Post: 09-29-2014, 11:35 AM
  4. Replies: 12
    Last Post: 05-30-2013, 02:02 PM
  5. Report based on Query but filtered by form
    By michel_annie22 in forum Reports
    Replies: 1
    Last Post: 10-23-2012, 10:40 PM

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