I just tested your code on one of my tables and corresponding form. After changing "%" to "*", it worked perfectly. What datatype is [Word]?
Main Topics
Browse All TopicsI created a custom search on a subform where the textboxes are not enabled and locked, so it will select the record. I am having a hard time using LIKE with wildcards. If I type the full name instead of the variable it works. I want it to find what I type in whichever area of the field.
I have changed the percentage sign with asterisk and it doesn't work.
Without the wildcard, if I enter the full correct word and it does work. The problem lies in the wildcard.
I have even tried using ALike and get the same result.
I am on Access 2007, but the file format is 2000 with the back end running on SQL Server 2005.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Key word - subform. Change line 7 to:
Set rst = Me.Form!sfmName.RecordsetC
have a read of http://www.mvps.org/access
was the FindNext the problem, or is that just a typo on the code you posted?
If you still have a problem, I think it may be because I forgot to use the single quote delimiter on the contents of the input box in strSearch. This change is in addition to one I gave you for strCriteria below.
strSearch = InputBox('Search')
strCriteria = "[Word] Like '%' & strSearch & '%' "
the reason I am asking you to try the single quote delimiter around parameters is because the use of the single quote delimiter is accepted by both Access Jet and T-SQL, whereas the double quote delimiter is accepted by
OK, I think I figured out your problem. You are not using the correct vba syntax for the InputBox function, which requires you to directly enter the values for each argument or assign the values to declared variables in a specific order. This is the line you need to fix:
strSearch = InputBox("Search")
see this link:
http://office.microsoft.co
Your example w/o an input box is using a double quote delimiter. Try it this way:
strSearch = 'MyWord'
strCriteria = "[Word] Like '" & strSearch & "'"
if the above does not work, remove the quotes entirely from strSearch. Your delimeters in strCriteria are probably sufficient.
strSearch = MyWord
strCriteria = "[Word] Like '" & strSearch & "'"
Papote,
Try this. If this does not work, I give up.
strSearch = InputBox("Search")
strCriteria = "[Word] Like '*" & strSearch & "*'" 'note single quote on each asterisk
__________________________
The above should produce a clause like this:
[Word] Like '*MyWord*'
assuming that the Input Box string contains the word "MyWord"
Check for missing vb library references. If references are ok, then it would appear to be a glitch in Access 2007. If you have not done it already, you should upgrade Office 2007 through SP2. There are still plenty of bugs in 2007. See this link :
http://allenbrowne.com/Acc
I'm using the code below without problems against a copy of the Address table out of the AdventureWorks db. The AddressLine1 is an NVarchar(60).
At this point -- things to check:
Can you do a full compile of the DB without errors? VBA Window --> Debug --> Compile MyDB.
Is the table updateable in the datasheet view?
Does the table have a PK on the SQL Side?
How big is the NVarchar field?
Have you tried it against a different field in the same table?
I just noticed that in 24859849 you said:
> The Text box I am searching is a combobox with a recordsource set to translate the ID Number to the string (nvarchar(50)).
Are you saying that the field [Word] is actually a numeric foreign key related to an ID number in another table, and that the corresponding text resides in that related table?
If so, then you are searching a numeric field for a text string and of course it won't work!
There are a lot of us playing guessing games here. Maybe you could post a loiilt more information about your table structure and relationships, including the RecordSource of your subform and the RowSource, ControlSource and BoundColumn of your combo box.
--
Graham Mandeno [Access MVP]
Business Accounts
Answer for Membership
by: peter57rPosted on 2009-06-29 at 09:03:43ID: 24737433
DAO uses * not %