Results 1 to 4 of 4
  1. #1
    obiron is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2011
    Posts
    8

    Question NULL vs. Empty String

    Hi guys,



    I have linked tables to an SQL2000 database. using Access 2007.

    I have a query that links CONTACTS to STAFF on a left join (staff_ID) and to INTERFACE on a left join (on CONTACTS.team and STAFF.Specialty)
    The staff record SHOULD always exist but Specialty may contain a string, NULL or be an empty string - I can't modify this data as it comes from an external system.

    I may have two records in the Interface table, one for Team = "XXX" and Specialty = "" and one for Team = "XXX" and specialty = NULL.

    The filter criteria are coming from a form which has the fields bound to the the INTERFACE records. I am trying to show the CONTACT records that match the INTERFACE record currently selected.

    I can't work out how to sucessfully test for the difference between null and empty string. Both isNULL() and NZ() seem to return true for both conditions.


    TIA

    Obiron
    Last edited by obiron; 08-02-2011 at 06:56 AM. Reason: Additional information

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Where (((Team) = "XXX") AND ((Speciality) = "" OR isnull(Speciality)))

  3. #3
    obiron is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2011
    Posts
    8
    Good try, but that will return records that match both interface lines because Access does not make a distinction between = "" and NULL. I only want to return records that only match ONE interface line. I need to be able to determine whether the form field is NULL or "" and then only return records from the query that match that form value.

  4. #4
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    so you are attempting to use "" to test your string if a record exists in the speciality and NULL to determine whether there is no specialty record at all?

    If so I'd probably use
    not isnull(specialtyID), isnull(specialtyname)
    for the staff with a specialty record but no specialty recorded
    and
    isnull(specialtyID) for the staff with no specialty record at all

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

Similar Threads

  1. Replies: 1
    Last Post: 07-07-2011, 08:32 PM
  2. saving records without null or empty fields
    By amber mara in forum Access
    Replies: 1
    Last Post: 05-05-2010, 02:34 PM
  3. empty field
    By amber mara in forum Access
    Replies: 2
    Last Post: 05-05-2010, 01:46 PM
  4. Go to first empty record
    By westcoastbmx in forum Forms
    Replies: 2
    Last Post: 10-30-2009, 01:37 PM
  5. Empty Lookup
    By mikel in forum Access
    Replies: 39
    Last Post: 08-07-2009, 01:00 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