Flexible Search and Wildcards

J

joann007

Hello all! I've created a flexible search like the one described by
Allen Browne at http://allenbrowne.com/ser-62.html. It works great
except that my supervisor just informed me that he would like to have
the ability to use a wild card * as search criteria on the form. The
textbox where he would be entering the criteria is called txtBillNo.
Here is the snippit of code I'm using:

'Search by bill #. Searches for similiar characters anywhere in the
field.
If Not IsNull(Me.txtBillNo) Then
strWhere = strWhere & "([Documents_Bill#] Like ""*" &
Me.txtBillNo & "*"") AND "
End If

Now, don't get me wrong, this works, just not how I had wanted. For
example, I type 39 in the textbox, looking for document 39C. I would
LIKE the form to display all the records with 39 somewhere in the
Documents_Bill#, with the most relevant answers first. However, these
are the kind of answers that I'm getting:

2391
39
1539
439
39C

How can I get it to return results that START WITH 39, not just have
it randomly placed somewhere in the Bill #?

Thanks!
-Joann
 
D

Douglas J. Steele

Lose the first asterisk:

strWhere = strWhere & "([Documents_Bill#] Like " & _
Me.txtBillNo & "*"") AND "
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top