Querying data from two fields

  • Thread starter Thread starter Steve Hart via AccessMonster.com
  • Start date Start date
S

Steve Hart via AccessMonster.com

I have a table that contains the fields Last_Name and Old_Last_Name, among
others. I'm looking to create a query that will return a record if either
of the fields matches a parameter entered by a user.

How can I accomplish this?

TIA,
Steve
 
Steve Hart via AccessMonster.com said:
I have a table that contains the fields Last_Name and Old_Last_Name, among
others. I'm looking to create a query that will return a record if either
of the fields matches a parameter entered by a user.

How can I accomplish this?

TIA,
Steve

Steve,

It should be something like:

PARAMETERS [Enter Search Parameter] TEXT(255);
SELECT T1.Last_Name
,T1.Old_Last_Name
FROM YourTable as T1
WHERE (T1.Last_Name = [Enter Search Parameter])
OR (T1.Old_Last_Name = [Enter Search Parameter]);


Or, for more flexibility:

PARAMETERS [Enter Search Parameter] TEXT(255);
SELECT T1.Last_Name
,T1.Old_Last_Name
FROM YourTable as T1
WHERE (T1.Last_Name LIKE "*" & [Enter Search Parameter] & "*")
OR (T1.Old_Last_Name LIKE "*" & [Enter Search Parameter] & "*");


(I saved them, so their syntax is ok, but didn't test them.)


Sincerely,

Chris O.
 
Back
Top