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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie Question - Creating if not, then query statement

Status
Not open for further replies.

marrah

Technical User
Oct 11, 2007
1
US
I'm trying to create a search that looks up (1)both first and last name (I have this part already based on a qbe that works fine), but if that combo doesn't exist, will pull up (2)either the first or last name. Example: If Jane Smith isn't in the table, it will pull up Jane Smyth, Jayne Smith, etc. The way it currently works, I get ALL of them and have to hunt for the combo I want... I only want part (2) to show up if part (1) doesn't exist. Is this possible?

Marrah
 
You should have posted your sql statement but let me guess hopping that there are kept in two fields
Code:
SELECT
FROM
WHERE LName = Forms!frmSearch.txtLastName AND
      FName = Forms!frmSearch.txtFirstName
if you replace the AND with OR
Code:
SELECT
FROM
WHERE LName = Forms!frmSearch.txtLastName OR
      FName = Forms!frmSearch.txtFirstName

you shall get Jane Smith & Jane Whatever & Whatever Smith

In case both names are in one field you 'll have to
Code:
SELECT
FROM
WHERE FullName Like Forms!frmSearch.txtLastName & "*" & Forms!frmSearch.txtFirstName
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top