Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Access (https://www.askmehelpdesk.com/forumdisplay.php?f=441)
-   -   Search in access (https://www.askmehelpdesk.com/showthread.php?t=179620)

  • Feb 2, 2008, 10:43 AM
    znet2705zc
    Search in access
    Hi !
    I creat a search query in ms access and when I want to find a special record in database ,
    The result is exactly the same input text that I enter the query. For example I want to find a name such as "abc", when a enter abc in query , the result show all records that their filed's name are "abc" but doesn't show the records that their fileds name is "abcd" or "abcde"...
    Is there any on to help me?
  • Feb 4, 2008, 07:52 AM
    MaggieMouse
    Try to key in abc*, which means anything starts with abc.
  • Feb 4, 2008, 07:57 AM
    ScottGem
    It depends on how you have created the search. If you are using a query, tyhen you have to use the LIKE operator:

    LIKE "abc*"

    Otherwise you will get only those that match abc*. You might want to check out the Filter by Form feature.
  • Mar 4, 2008, 11:51 AM
    znet2705zc
    Thanks,but I have still problem whit this.
    In my project there is a text box that we must enter the name, in the text box for search.
    For example when I enter "john" in the text box the result doesn't show "johnson" or like this, or when I enter "manchester" in the text box it doesn't show "manchester city" or "manchester united".
  • Mar 4, 2008, 11:55 AM
    ScottGem
    Like I said it depends on how you are doing the search. If you are setting criteria as I said using Like and an * it will work. For me to help further you need to describe what you are doing.
  • Mar 4, 2008, 12:03 PM
    znet2705zc
    I try to use this , but ms access show an error.
  • Mar 4, 2008, 12:13 PM
    znet2705zc
    In my query in front of criteria is : [forms]![search_form]![txt_firstname]
  • Mar 4, 2008, 12:28 PM
    ScottGem
    That's not gong to work like I said. That will only find an exact match you need to use:

    Like [forms]![search_form]![txt_firstname] & "*"
  • Mar 5, 2008, 10:23 AM
    znet2705zc
    Thank you very very much scottgem.
    That's OK, it solve my problem.
    I have another question too.
    As you know , if there is no result for the search, however query will be open.
    Is there any way to show a message if there is no result for the search.
    (without opening query).
  • Mar 5, 2008, 11:52 AM
    ScottGem
    Again, this depends on your code and how you are triggering the query. If you are running the query from VBA with a DoCmd.OpenQuery method, then you can use a DCount() function to check whehter the query returns any records and display a message if it doesn't.
  • Mar 5, 2008, 12:14 PM
    znet2705zc
    In my project there is a macro that it's action is : open query
    DoCmd.RunMacro
    Can you describe about DCount() function ?
  • Mar 5, 2008, 12:29 PM
    ScottGem
    Look it up in Access Help. I also recommend getting away from macros. You can't do what you want with macros since you can't run a conditional like that.
  • Mar 6, 2008, 09:51 AM
    znet2705zc
    Whit use this code it solve :
    If DCount("first_name]","[query_search_firstname]") = 0 Then
    msg=msgbox("Not Found")


    We can navigate between record's , in a form by using middle bottom of mouse,
    Can we disable it ?
  • Mar 6, 2008, 11:48 AM
    ScottGem
    Yep that looks like it would work.

    There is a utililty that can disable the wheel in Access forms. I can't find it right now, but if you search on Access Disable mousewheel you should find it.
  • Mar 9, 2008, 11:30 AM
    znet2705zc
    I found a way to disable mousewheel ( in form access) in this site:

    VBA Express : Access - Disabling Mouse Scroll wheel from advancing database entries

  • All times are GMT -7. The time now is 05:28 PM.