View Full Version : Search in access
znet2705zc
Feb 2, 2008, 10:43 AM
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?
MaggieMouse
Feb 4, 2008, 07:52 AM
Try to key in abc*, which means anything starts with abc.
ScottGem
Feb 4, 2008, 07:57 AM
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.
znet2705zc
Mar 4, 2008, 11:51 AM
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".
ScottGem
Mar 4, 2008, 11:55 AM
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.
znet2705zc
Mar 4, 2008, 12:03 PM
I try to use this , but ms access show an error.
znet2705zc
Mar 4, 2008, 12:13 PM
In my query in front of criteria is : [forms]![search_form]![txt_firstname]
ScottGem
Mar 4, 2008, 12:28 PM
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] & "*"
znet2705zc
Mar 5, 2008, 10:23 AM
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).
ScottGem
Mar 5, 2008, 11:52 AM
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.
znet2705zc
Mar 5, 2008, 12:14 PM
In my project there is a macro that it's action is : open query
DoCmd.RunMacro
Can you describe about DCount() function ?
ScottGem
Mar 5, 2008, 12:29 PM
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.
znet2705zc
Mar 6, 2008, 09:51 AM
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 ?
ScottGem
Mar 6, 2008, 11:48 AM
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.
znet2705zc
Mar 9, 2008, 11:30 AM
I found a way to disable mousewheel ( in form access) in this site:
VBA Express : Access - Disabling Mouse Scroll wheel from advancing database entries (http://www.vbaexpress.com/kb/getarticle.php?kb_id=890)