Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query limiting selection 1

Status
Not open for further replies.

ZOR

Technical User
Jan 30, 2002
2,963
GB
I have a record in the table of a persons name jusst being ABE. However if I put a space after my search field, the record in the list gets excluded.

& "WHERE Trim(TXCLIPS.NName) Like '*" & Replace(Me!LNAME10.Caption, "'", "''") & "*' " _

How can I overcome the problem? Many thanks
 
Perhaps this ?
& "WHERE Trim(TXCLIPS.NName) Like '*" & Trim(Replace(Me!LNAME10.Caption, "'", "''")) & "*' " _

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks, however still have the problem. A list shows name AEB, ABELARDO. if I enter ABE and a space, I still get the two names in the list and not just ABE.

Me!L10.RowSource = "SELECT TXCLIPS.NName AS Name" _
& " FROM TXMASTERS INNER JOIN TXCLIPS ON TXMASTERS.ID1=TXCLIPS.ID1 " _
& "WHERE Trim(TXCLIPS.NName) Like '*" & Trim(Replace(Me!LNAME10.Caption, "'", "''")) & "*' " _
& "ORDER BY 1"

I realised also in my last posting, the trim was in there so I took it out. I did want it in there as some records fields have unwated leading spaces. Thanks
 
More like this ?
Code:
Me!L10.RowSource = "SELECT C.NName AS Name" _
& " FROM TXMASTERS AS M INNER JOIN TXCLIPS AS C ON M.ID1=C.ID1 " _
& "WHERE C.NName & " " Like '*" & Replace(Me!LNAME10.Caption, "'", "''") & "*' " _
& "ORDER BY 1"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks PHV. It errors on " Like '*" saying its expecting an end of statement. Thanks
 
Sorry for the typo:
Code:
Me!L10.RowSource = "SELECT C.NName AS Name" _
& " FROM TXMASTERS AS M INNER JOIN TXCLIPS AS C ON M.ID1=C.ID1 " _
& "WHERE C.NName & ' ' Like '*" & Replace(Me!LNAME10.Caption, "'", "''") & "*' " _
& "ORDER BY 1"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks PHV, thats fixed the problem. I know it will come back on me though, as I noticed other records came up in the list as well.

ABE
Norick ABE

So I cannot think how that will sort out. Maybe to do it would be comparing the LEN values somehow. Any thought welcome, but have a star for this one.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top