Results 1 to 6 of 6
  1. #1
    offie is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2013
    Posts
    176

    Problems with searching with null values

    I have a field (Lets call it [A]) that has null values in it,


    For my criteria I want to search for "*" & [A] & "*" but when there is nothing in the search box I want it to show everything
    If I just put "*" I get all non-null values

    I came up with
    IIf([A] Is Null,Like "*" Or Is Null,Like "*" & [A] & "*")
    But it tells my that my expression is either wrong or too complex to evaluate when [A] is blank, when I enter in a value the table comes out blank


    When I change it to
    IIf([A] Is Null,Like "*" Or Is Null,[A])
    Same thing with blank but now the value works (though ultimately not what I want)

    What am I doing wrong? When I read it through it makes sense but obvioulsy it's not....

    Thanks!

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    I came up with

    if you have a criteria of like * & [value] & * it should be picking up both null and non-null values if [value] is null.

    If it's not try a criteria of

    Like * & [Value] & * or is null

  3. #3
    offie is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2013
    Posts
    176
    See the think is that I don't want the null values when something is searched, only when the nothing is searched

  4. #4
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    So you want if you have a [value] and it's populated you want to see anything that matches but if [value] is null you want to show only the null values?

  5. #5
    offie is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2013
    Posts
    176
    Ex: Field can have numberical values or be null

    If texbox on form contains 1, seach for all values that haves a 1 (do not show null values)

    If texbox is blank, show all values including null values

  6. #6
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Like [value] & *

    will show any item that STARTS with the value (1) or show EVERYTHING if value is null

    Like * & [Value] & *

    will show any item that has the value (1) ANYWHERE within it and shows EVERYTHING if the value is null

    Like * & [value]

    will show any item that ENDS with the value (1) or show EVERYTHING if value is null

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

Similar Threads

  1. Replies: 12
    Last Post: 04-07-2012, 12:09 PM
  2. Finding the Max Date and Null Values if Null
    By SpdRacerX in forum Queries
    Replies: 1
    Last Post: 02-03-2012, 06:29 AM
  3. Searching for values and making new tables
    By Chevlion42 in forum Programming
    Replies: 9
    Last Post: 10-10-2011, 11:55 AM
  4. Nz or IIF for problems with NULL
    By gap in forum Queries
    Replies: 2
    Last Post: 07-20-2011, 05:07 AM
  5. Replies: 1
    Last Post: 11-07-2010, 11:04 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