Search to recognise part of field

Slab_Rankle

Registered User.
Local time
Today, 11:34
Joined
Aug 10, 2011
Messages
36
Hey guys,

I have a form that allows a user to search for a client. There's currently 4 different ways the user can search, by account number, client name, postcode and creditor. Now, the clients name is stored as a full name, there's no seperate fields for first and last name. Typically a user will search for the last name first, but as it's stored as a 'full' name, it doesn't recognise any of the last name when the user types it into the search box. Is there a way to get Access to recognise part of the last name without the first name being in front of it? Currently this is my code:

If IsNull(Me.txtClientName) = False Then
strWhere = "ClientName like '" & Me.txtClientName & "*'"
End If

Now, I realise i've put 'name' a ridiculous amount of times in this post, so if it's confusing just say and I'll do a better job of explaining it! I basically want a user to type someones last name into txtClientName and have the form recognise the name without needing the first name. Any help would be greatly appreciated :).
 
Code:
If IsNull(Me.txtClientName) = False Then
strWhere = "ClientName like '[B][COLOR=red]*[/COLOR][/B]" & Me.txtClientName & "*'"
End If

Will find:

John Hancock
Hancock LTD
etc

JR
 
Thank you! That worked :). Hmm, I've tried searching for it on google but can't seem to find what I need, the strWhere line of code changes slightly when it's a number and not text, but I can't seem to find it anywhere. Which bit needs to be changed?
 

Users who are viewing this thread

Back
Top Bottom