Results 1 to 7 of 7
  1. #1
    2 Star Lounger
    Join Date
    Sep 2007
    Location
    Chatham, Kent, England
    Posts
    214
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Null Criteria (97)

    Morning all

    My database lists customer details. Each customer is given a customer type and the types are held in a seperate table.

    The boss wants a list of customers that have not been given a type.

    I've messed about with [is null] in a query of customers and types but it doesn't work, I'm guessing because there are no null types in the type table. I need to know the null types in the customer table.

    There is a nagging feeling in the back of my mind that I'm missing something simple here! I didn't get a lot of sleep over the weekend.

    Example db attached.

    TIA

    Regards

    Graeme
    Attached Files Attached Files

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Null Criteria (97)

    You don't need the tblType table in your query. Just create a query based on tblCust alone, add all fields, and in the criteria line under TypeID, enter Is Null.

    If you want to display both customers with and without a type, plus the description of the type, you must use a so-called outer join. Double click the line joining tblCust and tblType in your query, and select the option Include ALL records from 'TblCust' and only those records from 'TblType' where the joined fields are equal, then click OK. You will see that the line joining the tables is now an arrow from tblCust to tblType.

  3. #3
    4 Star Lounger SteveH's Avatar
    Join Date
    Jan 2001
    Location
    Chelsea, Gtr London, United Kingdom
    Posts
    587
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Null Criteria (97)

    SELECT TblCust.Cust, TblCust.TypeID
    FROM TblCust
    WHERE (((TblCust.TypeID) Is Null));

    should do the trick
    Steve H
    IT Lecturer/Access Developer
    O2K SR3/O2010; Win7Pro

  4. #4
    2 Star Lounger
    Join Date
    Sep 2007
    Location
    Chatham, Kent, England
    Posts
    214
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Null Criteria (97)

    Sorry for the panic! I've sorted it.

    The query needs to be based on just the Cust table and then the "is null" works on the TypeID foreign key.

    Thanks anyway to any one who looked. And sorry to any one who's time I've wasted.

    Regards

    Graeme

  5. #5
    2 Star Lounger
    Join Date
    Sep 2007
    Location
    Chatham, Kent, England
    Posts
    214
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Null Criteria (97)

    Hans

    Thanks for that.

    I spotted your reply after my 'don't worry about it' post.

    I need to read up on relationship types as all of the joins in the database are the defult type. So thanks for that.

    Regards

    Graeme

  6. #6
    2 Star Lounger
    Join Date
    Sep 2007
    Location
    Chatham, Kent, England
    Posts
    214
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Null Criteria (97)

    Steve

    Thanks for that.

    I spotted your reply after my 'don't worry about it' post.

    Not sure where to put your code but I'm sorted now anyway!

    Regards

    Graeme

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Null Criteria (97)

    I'm glad you sorted it out yourself.

    (BTW, it is not necessary to thank everyone who answered in a separate reply. You can post a single reply and mention that it is meant for all. See <!rule=07>Rule 07<!/rule>) <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •