Results 1 to 6 of 6
  1. #1
    MDelke is offline Novice
    Windows 7 32bit Access 2016
    Join Date
    Feb 2018
    Posts
    5

    Getting a result from select query where a field in one table is Null

    I have two Tables I am selecting from Click image for larger version. 
<br /><script async src=
    Name: tableControl.PNG  Views: 24  Size: 20.7 KB  ID: 45990" class="size_medium" />
    Click image for larger version. 

Name:	Table qso Master.PNG 
Views:	22 
Size:	22.3 KB 
ID:	45992

    Code:
     "SELECT QSO ID, Call
                FROM QSO - Master
                LEFT JOIN MRC - Control
                ON QSO MASTER.County ID = MRC Control.County ID
                WHERE MRC - Control.QSO ID Is NULL; ", conn)

    I am using Windows 10 and Access 2016
    I get Syntax error(missing operator) in query expression.

    Both tables have QSO ID, they both have county ID and they are both unique. But I only want the QSO's from QSO - Master that will fill the needs of the County ID from MRC - Control
    I am really new to writing other than simple SELECT statements. Any Help would be appreciated.
    I have included a snip of the two tables to hopefully clearify the situation.

    Thanks in advance

    Mike
    Last edited by MDelke; 08-18-2021 at 06:12 PM. Reason: It Gives wrong windows version

  2. #2
    ssanfu is offline Master of Nothing
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    It looks like you have ADO syntax (the ", conn) but I really think the error is because your object naming convention is not good.
    Object names should:
    ---------------------------------------------------------------------------
    Use only letters and numbers (exception is the underscore) for object names.
    Do not use spaces, punctuation or special characters in object names.
    ---------------------------------------------------------------------------
    You have spaces and hyphens in the names.

    Maybe something like:
    Code:
     "SELECT QSOID, Call
      FROM QSO_Master LEFT JOIN MRC_Control ON QSO_MASTER.CountyID = MRC_Control.CountyID
      WHERE MRC_Control.QSOID Is NULL; ", conn)
    BTW, "CALL" is a reserved word in Access and shouldn't be used for object names.

  3. #3
    MDelke is offline Novice
    Windows 7 32bit Access 2016
    Join Date
    Feb 2018
    Posts
    5
    I Understand what you are saying. The problem is I am getting the info from a program I didnt write. I am using its Database's to get the info for my program. and there are a few hundred Amatuer Radio Operators using the program already. I am writing a program as a utlity to make the other program more useful.

    Mike

  4. #4
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,799
    Maybe the best you'll be able to do is wrap these names in brackets in your sql: [QSO - Master] not QSO - Master and so on.
    Those are some of the worst object names I've ever seen in programming!
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    Minty is online now VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    Create a query on each of the tables and redefine the names to something sensible. e.g.

    SELECT [QSO ID] as QSO_ID, [Call] as CallValue FROM [QSO - Master]

    Then Save that query as qryQSOMasterTable or something else without any spaces or weird characters.

    Then base all your queries on those queries.
    This will save you a ton of pain with square brackets everywhere.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  6. #6
    MDelke is offline Novice
    Windows 7 32bit Access 2016
    Join Date
    Feb 2018
    Posts
    5
    Thank You to all that gave their ideas. Guess I will just wrap the misguided nameing in the other program on [] as there are only a couple of screens to do searchs for.

    THANKS AGAIN
    Mike

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

Similar Threads

  1. Replies: 3
    Last Post: 09-12-2013, 02:18 PM
  2. Populate Field when result is Null
    By BarneyH4 in forum Queries
    Replies: 3
    Last Post: 06-25-2013, 11:03 AM
  3. Replies: 1
    Last Post: 08-31-2012, 01:56 PM
  4. Replies: 1
    Last Post: 02-23-2012, 02:27 PM
  5. If Query result Is Null...MsgBox..Okl
    By Bruce in forum Forms
    Replies: 28
    Last Post: 03-10-2010, 10:57 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