I have a search form. In the search form I have a first name field and a last name field. I want it to be able to search by first or last name.
If I enter only a last name (Smith)I should get results of all people with last name Smith.
If I enter only a first name (John)I should get results of all people with first name Smith.
If I enter a first name, John, AND a last name, Smith, I should get specific results matching that criteria.
I have a search button connecting to a query.
Here is my sql for the query:
SELECT tblClient.lastname, tblClient.firstname
FROM tblClient
WHERE
(((tblClient.lastname)IIf(IsNull([Forms]![frmSearch Multiple]![lastname]),"*",[Forms]![frmSearch Multiple]![lastname]))
AND ((tblClient.firstname)IIf(IsNull([Forms]![frmSearch Multiple]![firstname]),"*",[Forms]![frmSearch Multiple]![firstname])));
This will give me a results if I have entered both fields. If I only enter one and not the other(null) then it will not work.
Please help!
If I enter only a last name (Smith)I should get results of all people with last name Smith.
If I enter only a first name (John)I should get results of all people with first name Smith.
If I enter a first name, John, AND a last name, Smith, I should get specific results matching that criteria.
I have a search button connecting to a query.
Here is my sql for the query:
SELECT tblClient.lastname, tblClient.firstname
FROM tblClient
WHERE
(((tblClient.lastname)IIf(IsNull([Forms]![frmSearch Multiple]![lastname]),"*",[Forms]![frmSearch Multiple]![lastname]))
AND ((tblClient.firstname)IIf(IsNull([Forms]![frmSearch Multiple]![firstname]),"*",[Forms]![frmSearch Multiple]![firstname])));
This will give me a results if I have entered both fields. If I only enter one and not the other(null) then it will not work.
Please help!