Results 1 to 13 of 13
  1. #1
    atom is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Jan 2012
    Posts
    43

    Searching based on form shows only records with values

    Hello everyone,
    I have a query that returns some results based on user input in form.
    The field in query is text .
    In the criteria of this query I have tried the following:
    1.
    Code:
    Like Nz([Forms]![SearchForm]![txt];"*")

    2.
    Code:
    Like "*"&[Forms]![SearchForm]![txt]&"*"
    3.
    Code:
    Like [Forms]![SearchForm]![txt]&"*"

    The field in the query contains blank values.
    So whatever I tried I get only the records where the field in the query has values.


    Is there another way to display all values and only the specified when user searches?


    thank you in advance

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    The field is text type for a date value?

    Using Like and wildcard doesn't really make sense for a date value. Do users input only a partial date as criteria?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    atom is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Jan 2012
    Posts
    43
    My wrong .
    I edited my post .
    The user enters text as input

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    Your post still states 'The field in query is text .'

    Like and wildcard doesn't return records with null, no matter what the datatype is. I seldom use query parameters because of their inflexibility. Review this http://allenbrowne.com/ser-62.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    atom is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Jan 2012
    Posts
    43
    Yes the field in my query is text
    I will check the link you posted
    Thank you for your replies

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    You have date values in a text datatype field - why?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    atom is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Jan 2012
    Posts
    43
    Lol !Big misunderstanding ....
    The user enters text as criteria in a text field. The date thing ,was a typographical error at first post .
    I posted
    Code:
    Like Nz([Forms]![SearchForm]![txtDate];"*")
    by mistake
    I should post
    Code:
    Like Nz([Forms]![SearchForm]![txt];"*")


    Thank you for your patience

  8. #8
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,847
    What exactly do you expect or want this to find?
    Like Nz([Forms]![SearchForm]![txt];"*")
    Details of Nz() are here http://www.techonthenet.com/access/f...dvanced/nz.php

    If you use Like and you want to find things that:
    start with whatever is in
    [Forms]![SearchForm]![txt], you would write
    ... Like [Forms]![SearchForm]![txt] & "*"

    end with whatever is in
    [Forms]![SearchForm]![txt], you would write
    ... Like "*" & [Forms]![SearchForm]![txt]

    contain whatever is in
    [Forms]![SearchForm]![txt], you would write
    ... Like "*" & [Forms]![SearchForm]![txt] & "*"

  9. #9
    atom is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Jan 2012
    Posts
    43
    Thanks for your response.
    My problem is that whatever criteria I enter on query I get records that contain values , ignoring blanks .
    If I enter
    Code:
    or IsNull
    in criteria , the search doesn't work obviously

  10. #10
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,847
    So you want everything including blanks or nulls etc?


    Suppose you had records:
    .........{Searched field}
    A........XYZ
    B........JKL
    C........[NULL] or blank
    D........123K

    and you searched

    .....SearchField Like "*" & "K" & "*"

    What records do you want returned? If this example isn't clear enough, or not addressing your issue, please make up an example that highlights your intent.

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    So the field is a date datatype?

    Did you review the Allen Browne link?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  12. #12
    atom is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Jan 2012
    Posts
    43
    Quote Originally Posted by orange View Post
    So you want everything including blanks or nulls etc?


    Suppose you had records:
    .........{Searched field}
    A........XYZ
    B........JKL
    C........[NULL] or blank
    D........123K

    and you searched

    .....SearchField Like "*" & "K" & "*"

    What records do you want returned? If this example isn't clear enough, or not addressing your issue, please make up an example that highlights your intent.
    That's exactlyp what I want.

    My results are :


    B........JKL
    D........123K

    but when the search field is left blank I have
    A........XYZ
    B........JKL
    D........123K

  13. #13
    atom is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Jan 2012
    Posts
    43
    The field is text and the user's input is text also .
    Date was a typo I did in first post!

    Thank you for your replies

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

Similar Threads

  1. Replies: 8
    Last Post: 02-26-2012, 09:48 PM
  2. Searching for values and making new tables
    By Chevlion42 in forum Programming
    Replies: 9
    Last Post: 10-10-2011, 11:55 AM
  3. Select record based on values of other records
    By dchaboya in forum Queries
    Replies: 2
    Last Post: 08-11-2011, 10:41 AM
  4. Replies: 10
    Last Post: 01-10-2011, 07:52 PM
  5. Report based on query shows no data
    By hbograd in forum Reports
    Replies: 2
    Last Post: 12-18-2009, 12:28 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