Results 1 to 11 of 11
  1. #1
    Marine9925 is offline Novice
    Windows 11 Office 365
    Join Date
    Dec 2024
    Posts
    1

    Ivvalid query results

    I have a table that has the following records...


    [txt_PersonalityName] a "Short Text" field


    FISD-Mobile-Admin
    FISD-Portable-Admin
    FISD-Mobile-General
    FISD-Portable-General
    FISD-Mobile-Security
    FISD-Portable-Security


    1) I have created a form with a search box allowing the user to enter the search criteria for the query.


    2) the query has the following search criteria... [ Like "*" & [Forms]![frm_PersonalitiesList]![txt_PersonalityNameSearch] & "*" ]


    Results


    If the user enters "F" in the search criteria txt box, all records are returned;


    If the user enters "Anything Else", i.e. "FI", "FISD", "G" or "P", no records are returned even thou they are in the table;


    Any idea what I am doing wrong?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Is this field a Lookup field in table?

    Suggest you provide db for analysis. Follow instructions at bottom of my post.
    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
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    Well you should not have [ and ]around the criteria I would have thought?
    Upload a DB with enough data to see the issue.
    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

  4. #4
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,931
    The are a number of ways to filter a form. To your description implies you are modifying the underlying query. If you are modifying the query then you need to requery

    It would help us to help you if you provided the code you are actually using - descriptions are a waste of time

  5. #5
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,931
    The are a number of ways to filter a form. To your description implies you are modifying the underlying query. If you are modifying the query then you need to requery

    It would help us to help you if you provided the code you are actually using - descriptions are a waste of time

    If the user enters "F" in the search criteria txt box, all records are returned
    what happens if the user enters”I”?

  6. #6
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    I would have thought
    Like "*'" & [Forms]![frm_PersonalitiesList]![txt_PersonalityNameSearch] & "'*" and not
    Like "*" & [Forms]![frm_PersonalitiesList]![txt_PersonalityNameSearch] & "*"
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #7
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    No, I checked what I use in my diabetes DB. Although the value is taken from an input box and passed to a tempvar, this works.
    Code:
    SELECT tblFoods.*
    FROM tblFoods
    WHERE (((tblFoods.FoodName) Like "*" & [Tempvars]![Food] & "*"));
    Attached Thumbnails Attached Thumbnails Screenshot 2024-12-24 191227.png  
    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
    June7's Avatar
    June7 is offline VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Need apostrophe delimiters when building SQL string in VBA. Unless using RunSQL and embedding full form/control path reference in string. Query object does not require - as shown in the Immediate Window output, Access will supply for the compiled SQL statement.
    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.

  9. #9
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    No, I checked what I use in my diabetes DB
    That is basically what I wrote, except I put the single quotes on the wrong side of the asterisks?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Welsh is not using apostrophes at all in the query structure. See my previous post.
    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.

  11. #11
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    Quote Originally Posted by Micron View Post
    That is basically what I wrote, except I put the single quotes on the wrong side of the asterisks?
    I only used the quotes for the DCount criteria.
    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

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

Similar Threads

  1. Replies: 6
    Last Post: 08-21-2019, 07:17 AM
  2. Replies: 2
    Last Post: 04-15-2017, 11:09 AM
  3. Replies: 5
    Last Post: 05-21-2013, 02:21 PM
  4. Replies: 3
    Last Post: 05-02-2013, 10:36 AM
  5. Replies: 6
    Last Post: 05-14-2012, 07:24 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