Trouble with "*" wildcard

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Sir/Ma'am,
I currently have a query built to search for a text string in any part
of the field. The problem that I am running into was that when I use Like "*"
& [What is the name of the person you are looking for?] & "*", I get
everything, even when it has nothing to do with the value the user entered.
Like if the user entered "Doe", They would get John Smith. I've read through
the forum and it appears that should work, but mine is pulling up all the
records. I will post the code for everyone to view, and see where I might be
going wrong.

SELECT TblBlotter.*, TblExtras.* INTO TblSearch
FROM TblBlotter LEFT JOIN TblExtras ON TblBlotter.BlotterID =
TblExtras.BlotterID
WHERE (((TblBlotter.DeskSergeant) Like "*" & [Who is the Desk Sergeant that
you are searching for?] & "*"));
 
I don't have your tables, but ran query on some other tables.
My WHERE statement - WHERE (((Students.Surname) Like "*" & [Enter a Name?] &
"*"));

Works for me... gives me 1 record from a table containing 141 records.
Maybe your join needs to be looked at.

Break your problem down.... create query based on one table first. Does that
work?
If yes, add next table and joins, run query again.
Sir/Ma'am,
I currently have a query built to search for a text string in any part
of the field. The problem that I am running into was that when I use Like "*"
& [What is the name of the person you are looking for?] & "*", I get
everything, even when it has nothing to do with the value the user entered.
Like if the user entered "Doe", They would get John Smith. I've read through
the forum and it appears that should work, but mine is pulling up all the
records. I will post the code for everyone to view, and see where I might be
going wrong.

SELECT TblBlotter.*, TblExtras.* INTO TblSearch
FROM TblBlotter LEFT JOIN TblExtras ON TblBlotter.BlotterID =
TblExtras.BlotterID
WHERE (((TblBlotter.DeskSergeant) Like "*" & [Who is the Desk Sergeant that
you are searching for?] & "*"));
 

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

Back
Top