Results 1 to 6 of 6
  1. #1
    robmict is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    3

    Query and if null

    Hello all, I am trying to build a query that will tell me
    1. If my EMT's licenses will expire within the next 2 months
    2. If they have all their NIMS completed
    3. If any of these items are blank in my database.
    I have two tables I am using
    1. Contacts
    2. NIMS
    I have set it up so that if their licenses are expiring in the time frame it tells me yes or no, I have done this by putting the following in the field line of my query in design view.
    Need EVOC Renewal: IIf([Contacts]![EVOC Last Date Taken]<(Date()-730),"YES","NO")
    This tells me either yes they need evoc (Emergency Vehicle Operators Course, or no they do not, and it works fine but it if the data for the record is not entered I still get "NO" which I will then overlook the fact the EMT may never have had EVOC. I am sorry if my lingo is incorrect, and please let me know if you have any questions that will help you help me. Thank you for your time and response in advance.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Try wrapping the field reference in the Nz() function to replace Null with some date old enough to fail your test. More info on the Nz() function in Help.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    robmict is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    3
    Could you please give me an example of this, and where to put it in my query while in design view, I can't seem to get it to work even with the help menu.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Untested, but try

    Need EVOC Renewal: IIf(Nz([Contacts]![EVOC Last Date Taken], #1/1/2000#)<(Date()-730),"YES","NO")

    The spaces in your names are going to prove more trouble than they're worth in the long run.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    robmict is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    3
    Paul, you are my hero, so far so good, I also now understand what I was doing wrong with my Nz function. Thank you very much!!!

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Happy to help, and welcome to the site by the way!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. If Query result Is Null...MsgBox..Okl
    By Bruce in forum Forms
    Replies: 28
    Last Post: 03-10-2010, 10:57 AM
  2. Null Values in query
    By LesleaOH in forum Queries
    Replies: 0
    Last Post: 10-19-2009, 04:45 PM
  3. Query including Null relationship?
    By David Criniti in forum Database Design
    Replies: 0
    Last Post: 08-14-2009, 09:10 PM
  4. Query returns null..based on two tables
    By shsh_shah in forum Queries
    Replies: 1
    Last Post: 03-08-2009, 01:45 PM
  5. Null Values not showing up in a Query
    By Valli in forum Queries
    Replies: 0
    Last Post: 01-04-2006, 03:53 PM

Tags for this Thread

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