Results 1 to 6 of 6
  1. #1
    GrahamGC is offline Novice
    Windows 11 Access 2021
    Join Date
    Mar 2023
    Posts
    2

    non matching query wizard doesnt seem to give correct result


    I have 2 tables - T-Class info, and T-entries. Field Class no is in both tables, but I want to find the records where class no does not appear in the entries table. The query the wizard has created (SQL below) shows a lot of correct records, but misses some, and , but includes others that should not be there.
    SQL is: SELECT [T-Class info].[Class No]
    FROM [T-Class info] LEFT JOIN [T-Entries] ON [T-Class info].[Class No] = [T-Entries].[Class No]
    WHERE ((([T-Entries].[Class No]) Is Null));
    Ideas?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,892
    Is Class No a text field? Could field have empty string instead of be Null?

    If you want to provide db for analysis, follow instructions at bottom of my post.

    Strongly advise not to use spaces nor punctuation/special characters in naming convention.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,409
    think you need to provide some example data of those missed or should not be included i.e. what's in the class table and what's in the entries table that causes you to think this.

  4. #4
    GrahamGC is offline Novice
    Windows 11 Access 2021
    Join Date
    Mar 2023
    Posts
    2

    File attached

    Quote Originally Posted by June7 View Post
    Is Class No a text field? Could field have empty string instead of be Null?

    If you want to provide db for analysis, follow instructions at bottom of my post.

    Strongly advise not to use spaces nor punctuation/special characters in naming convention.
    ClassNo (spaces removed) is a number field. File attached.
    Note that ClassNo 30, 50, 52, etc are in the T-Entries table, so should not come out in the 'Q-T-Class info Without Matching T-Entries -2' query. Also ClassNo 24, 25, 26, etc are not in the T-Entries table, so should be in the query result.

    Copy of Spring Show.zip

  5. #5
    orange's Avatar
    orange is online now Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    Have these tables or data within been manipulated or obtained from some other application?
    When I run a query to show ClassNo that are equal in both tables. I see strange/unexpected results.

    Query1 sql
    Code:
    SELECT [T-Class info].ClassNo
    , [T-Entries].ClassNo
    FROM [T-Entries] INNER JOIN [T-Class info] ON
     [T-Entries].ClassNo = [T-Class info].ClassNo;
    Part of result set.

    Click image for larger version. 

Name:	Screenshot 2023-03-03 082648.png 
Views:	13 
Size:	30.5 KB 
ID:	49830

    I did check your EntrantNo in your tables and they are as expected/matching.

    It appears to be some sort of (data) corruption with your ClassNo????

    UPDATE: CJ has identified the issue in post #6. I don't use field lookups and didn't check--my bad.
    Last edited by orange; 03-03-2023 at 09:40 AM.

  6. #6
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,409
    it is because you are using lookups in your table design.

    In T-Entries you are storing the class ID, not classNo. But because of the lookup you are seeing classNo. General not a good idea to have lookups in table design - or anything that hides the actual data such as formatting. Causes lots of confusion such as this

    Modify your query to link

    ON [T-Class info].ID = [T-Entries].ClassNo

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

Similar Threads

  1. Replies: 7
    Last Post: 08-31-2022, 05:12 PM
  2. The statemewnt give the same result
    By Lou_Reed in forum Access
    Replies: 3
    Last Post: 04-06-2017, 06:47 AM
  3. Replies: 2
    Last Post: 11-08-2015, 03:44 PM
  4. Replies: 6
    Last Post: 09-02-2012, 04:30 PM
  5. Command Button Wizard and Matching Fields
    By tylerg11 in forum Forms
    Replies: 5
    Last Post: 10-07-2011, 01:07 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