Search - trouble with "Like"

Montez659

Well-known Member
Joined
May 4, 2005
Messages
918
I am having a hard time understanding what I am doing wrong with this search string (this is in a query). Here it is:
Code:
Like [Tasks].[Tax ID] Or Like [Tasks].[Description]
I have also tried
Code:
Like "*" & [Tasks].[Description] & "*" Or Like [Tasks].[Tax ID]

The first one does not return what I need and the second returns more than I need. The problem seems to lie in the [Tasks].[Description] field, which is a memo field. The Tax ID field is a text field and it seems to be returning what it is supposed to.

Thanks in advance for the help!
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Can you tell us what your searching for?
 
Upvote 0
My bad, I forgot to include everything. Here is the SQL:
Code:
SELECT Tasks.ID, Tasks.Title, Tasks.[Start Date], Tasks.[Assigned To], Tasks.[Tax ID]
FROM Tasks
WHERE ((([Forms]![frmRequests]![reqTax]) Like [Tasks].[Description] Or ([Forms]![frmRequests]![reqTax]) Like [Tasks].[Tax ID]));

Basically, in the O n Current Event of the frmRequests, I want to fill a listbox with possible matches to what is entered in the frmRequests Tax ID box (reqTax). This can be in two possible places - Tasks.Tax ID or Tasks.Description. It seems that the first string of code that I posted is returning matches in the Tax ID field, but the Description field is giving me problems.

Oh, and they are text, but the description field is memo.

Hope this is enough info for ya!
 
Upvote 0
Hmmm, I think I may have reversed the variable and field in the Like statements.
Code:
WHERE (((Tasks.[Tax ID]) Like [Forms]![frmRequests]![reqTax])) OR (((Tasks.Description) Like "*" & [Forms]![frmRequests]![reqTax] & "*"));

Yep, that seems to be it. The above works.
 
Upvote 0
I always get that sort of thing the wrong way round.

More with InStr though.
 
Upvote 0

Forum statistics

Threads
1,224,582
Messages
6,179,670
Members
452,936
Latest member
anamikabhargaw

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top