Results 1 to 4 of 4
  1. #1
    civl_eng is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    41

    filter subform by records dont exist in query

    hi all, i have a query and a table2, and i created subform from table2, now i want to filter subform based on records that don't exist in query (query1) from same id in tow object. is it possible to do?

    My querry1 from table 1 :



    Click image for larger version. 

Name:	Screenshot (737).png 
Views:	13 
Size:	7.2 KB 
ID:	35031

    table2 :

    Click image for larger version. 

Name:	Screenshot (738).png 
Views:	13 
Size:	10.8 KB 
ID:	35032

    Subform of Table2 based on query1 :

    Click image for larger version. 

Name:	Screenshot (739).png 
Views:	13 
Size:	8.2 KB 
ID:	35034

  2. #2
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,845
    use a left join to join your table to your query and filter out the records which have a match - something like

    SELECT Table1.*
    FROM Table1 LEFT JOIN Query1 ON Table1.K1=Query1.K1
    WHERE Query1.K1 IS NULL

  3. #3
    civl_eng is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    41
    hey,,thank you for reply,,,but it doesn't work for me..and i get this error :

    Click image for larger version. 

Name:	Screenshot (744).png 
Views:	9 
Size:	5.3 KB 
ID:	35084


    i type this code for sql :

    Dim pSQL As String


    pSQL = "SELECT Table1 * FROM Table1 LEFT JOIN Query1 ON Table2.K1=Query1.K1 WHERE Query1.K1 Is Null "


    Me.Table2_Sub.Form.RecordSource = pSQL
    Me.Table2_Sub.Requery

  4. #4
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,845
    you are missing a .

    SELECT Table1 *

    also there is no Table2 - ON Table2.K1=Query1.K1

    You are mixing up the code I provided with the tables and query you originally provided

    Always better to give tables/fields meaningful names

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

Similar Threads

  1. Replies: 6
    Last Post: 03-17-2017, 10:28 PM
  2. Replies: 4
    Last Post: 07-10-2015, 07:51 AM
  3. Replies: 4
    Last Post: 03-03-2015, 01:36 PM
  4. Combo box to filter records in a subform
    By dannybeaver in forum Access
    Replies: 9
    Last Post: 08-27-2014, 02:14 AM
  5. macros in subform dont work
    By tuyo in forum Access
    Replies: 2
    Last Post: 03-25-2011, 09:49 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