Page 1 of 5 12345 LastLast
Results 1 to 15 of 64
  1. #1
    guest is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Dec 2024
    Posts
    61

    wrong search results


    Hi,
    I have problem with my form for searching records. It contains sub form which open full table with all records and combo boxes for searching fields. I have problems with date search combo box. if all date fields are filled everything is fine, but if i have empty date field than that record containing empty date field is added to search results no mater what field i am searching with. my after update event for searching records is macro containing where conditions ="[Fieldname] = " & "'" & [Screen].[ActiveControl] & "'". my query criteria for date field is Like "*" & [forms]![Formname].[comboname] & "*" or is null. what i get when i search is this Click image for larger version. 

Name:	Untitled1.jpg 
Views:	57 
Size:	97.3 KB 
ID:	52473 in this example searching was done with first combo box entering value 10 and I get first two records which supposed to be and third record with empty date field which is added but aint supposed to be shown. same thing happens if i search with date field or any other. i get search results plus record with empty date field.
    thanks
    is been send too pcreview too not answer. here is the link https://www.pcreview.co.uk/search/112657/?c[users]=unknownuser&o=date

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,569
    So the date field is Null and you ask for
    my query criteria for date field is Like "*" & [forms]![Formname].[comboname] & "*" or is null.
    is been send too pcreview too not answer. here is the link https://www.pcreview.co.uk/search/112657/?c[users]=unknownuser&o=date
    This has been crossposted at https://www.access-programmers.co.uk...-table.332915/
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    guest is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Dec 2024
    Posts
    61
    In query is null is added to get all records in the searching. if i delete is null from the query that record will be omitted from searching. Solution?

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,569
    Quote Originally Posted by guest View Post
    In query is null is added to get all records in the searching. if i delete is null from the query that record will be omitted from searching. Solution?
    Which is what you are after?, Yes?

    and third record with empty date field which is added but aint supposed to be shown
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  5. #5
    guest is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Dec 2024
    Posts
    61
    I want query to show all records for searching. i might search for data even from the record with empty date field. If I exclude that record from searching i might miss what I need to find and wont be shown in the search. I dont know how to fix this. I get one or another. searching all records with added plus record or exact search if searching is not related to that record (in case it is related will be missing).

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Wildcards are really only useful for text data. Review 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.

  7. #7
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,569
    I want query to show all records for searching. i might search for data even from the record with empty date field
    You search on what you need to search on.
    Anytime you use Or Null on a field, that is what you are going to get, regardless of what you are searching on. So if that Null date field record had 10, you would have had that with your search, but you brought that in becauuse you said OR null for the date field, so you would also get every record with a Null in that date field.

    It is called logic for a reason.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  8. #8
    guest is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Dec 2024
    Posts
    61
    For now I replaced empty date field with date 1-1-1900.
    Thanks

  9. #9
    guest is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Dec 2024
    Posts
    61
    I made it sort of with little cheating. I changed empty date field with 1-1-1900 and then with conditional formatting made font color same as background color so it looks like empty but because there is something search work too. Problem solved.

  10. #10
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,569
    You will likely forget that in a couple on months or so? then be wondering why something does not work.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  11. #11
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,879
    I'm not a fan of placeholder records either. I prefer to deal with the nulls.

    Is your date field a date datatype? I ask because the 8th column over appears to be a date field but some records contain a \ which would indicate it is text datatype.

    I think I'd try using a filter rather than a query.
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  12. #12
    guest is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Dec 2024
    Posts
    61
    table contain all types of data field: text, numeric, date and link. / is instead of empty field maybe more familiar for you will be N/A. i tried to eliminate empty fields they may be problematic. I only use them when i must to have empty field. if there is no combo box for some field it is not important field is empty or not.

  13. #13
    guest is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Dec 2024
    Posts
    61
    Problem is that i am a novice. don't know macro sql vba or anything like that.

  14. #14
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,822
    Hi
    Can you upload a copy of the database?

  15. #15
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,569
    The problem is you are asking for a null date and then getting any that exist?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

Page 1 of 5 12345 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 01-25-2024, 02:46 PM
  2. Replies: 2
    Last Post: 04-15-2017, 11:09 AM
  3. Replies: 3
    Last Post: 09-12-2016, 11:49 AM
  4. Replies: 3
    Last Post: 09-02-2013, 04:33 PM
  5. Search form getting wrong results
    By Ruegen in forum Programming
    Replies: 1
    Last Post: 08-22-2013, 06:32 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