Search Function typo?

Huey462

Board Regular
Joined
Jul 25, 2011
Messages
147
Let me preface this with an apology, I’ve been at work way too long and my brain function hovering between a rock and a zombie. If I omitted something or you need further clarification please do not hesitate to ask.
My search function is not working, and I don’t know why, I’m guessing a errant comma or something. Any help would be greatly appreciated. I have one entry from someone with the last name of “Smith”.
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
Table information is called “SupplyLog”
<o:p></o:p>
Search Form with textboxes to type in search criteria is called “SearchForm”
The name/requestor field is called “Qreq1”
<o:p></o:p>
When the search button is clicked, the form Printable2005 is opened. The data for this form is a query called “FloorReport”
<o:p></o:p>
The criteria for the Requestor field is
Code:
Like "*" & [forms]![SearchForm].[QReq1] & "*"
<o:p></o:p>
I have tried running this both with and without loading/opening the query and the results are the same. Like I said before, I’m guessing my problem lies with the like function, but I’m at a loss.
 
Last edited:

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Please post all of the code behind the form.

Please show us the code associated with
When the search button is clicked,

Where is the code/logic by which
form Printable2005 is opened?
 
Upvote 0
I went through all of the like functions and found the one that was causing the problem, I don't know why this would be the culprit...everything looks good.

Code:
Like "*" & [forms]![SearchForm].[QReq1] & "*"
Like "*" & [forms]![SearchForm].[QJCN1] & "*"
Like "*" & [forms]![SearchForm].[QDoc1] & "*" (PROBLEM)
Like "*" & [forms]![SearchForm].[QStatus1] & "*"
Like "*" & [forms]![SearchForm].[QNoun1] & "*"
Like "*" & [forms]![SearchForm].[QNSN1] & "*"
Like "*" & [forms]![SearchForm].[QPN1] & "*"

My best guess is that if there is nothing in the field searched by the QDOC1, it comes up with nothing, so there needs to have some sort of value in there rather than a NULL/Empty
 
Upvote 0
Can you post the query code?
How do these Like statements fit together

eg, Like A AND Like B?

If any of these fields could be NULL (no VALUE) you may have to check for that

eg

If (Is NULL(forms]![SearchForm].[QReq1] )) then

'display message
msgbox "You must supply a value for qReq1",vbYesNo,"Warning"
else
' OK carry on
endif
 
Upvote 0
I found the problem, in the search form the Document # field was linked to the table rather than having nothing linked to it. Thank you for the responses though :)
 
Upvote 0

Forum statistics

Threads
1,214,834
Messages
6,121,871
Members
449,054
Latest member
juliecooper255

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