C
ChicagoPete
Help with AND/OR, IIF, ISNULL, ISNOTNULL, LIKE??
In my simplified example, I have Last Name, First Name, DOB, Document Type
(receipt, check, invoice) and location.
Here is my SQL code from the Access2007 Query, problem is the end-user may
only have 1 or more pieces of data to perform a search, they may also only
have a partial Last Name or worse an inproperly spelled last name - so I need
a few different scenarios to perform my query and my OR statements don't cut
it any more.
The user may type SMITH in the last name field, which returns a lot of data
and currently if they enter SMITH and JOE they get all the Smith's and all
the Joe's, due to my many OR statements. What is needed, and I can't seem to
get it right is the ability to search on any one and/or all fields. The user
may also type the first few characters of a last name. I guess I need a mix
of operators such as LIKE, IS NOT NULL etc... Maybe the ability to search for
all invoices from Joe Smith?
Any help/ideas as I know someone has dealt with this before.
Thanks in advance
****snip****
SELECT tblMain.LastName, tblMain.FirstName, tblMain.DOB,
tblMain.DocumentType, tblMain.Location,
FROM tblMain
WHERE (((tblMain.LastName)=[forms]![frmSearch]![LastName])) OR
(((tblMain.FirstName)=[forms]![frmSearch]![FirstName])) OR
(((tblMain.DOB)=[forms]![frmSearch]![DateOfBirth])) OR
(((tblMain.DocumentType)=[forms]![frmSearch]![DocumentType])) OR
(((tblMain.Location)=[forms]![frmSearch]![Location]));
****end snip ****
Pete
In my simplified example, I have Last Name, First Name, DOB, Document Type
(receipt, check, invoice) and location.
Here is my SQL code from the Access2007 Query, problem is the end-user may
only have 1 or more pieces of data to perform a search, they may also only
have a partial Last Name or worse an inproperly spelled last name - so I need
a few different scenarios to perform my query and my OR statements don't cut
it any more.
The user may type SMITH in the last name field, which returns a lot of data
and currently if they enter SMITH and JOE they get all the Smith's and all
the Joe's, due to my many OR statements. What is needed, and I can't seem to
get it right is the ability to search on any one and/or all fields. The user
may also type the first few characters of a last name. I guess I need a mix
of operators such as LIKE, IS NOT NULL etc... Maybe the ability to search for
all invoices from Joe Smith?
Any help/ideas as I know someone has dealt with this before.
Thanks in advance
****snip****
SELECT tblMain.LastName, tblMain.FirstName, tblMain.DOB,
tblMain.DocumentType, tblMain.Location,
FROM tblMain
WHERE (((tblMain.LastName)=[forms]![frmSearch]![LastName])) OR
(((tblMain.FirstName)=[forms]![frmSearch]![FirstName])) OR
(((tblMain.DOB)=[forms]![frmSearch]![DateOfBirth])) OR
(((tblMain.DocumentType)=[forms]![frmSearch]![DocumentType])) OR
(((tblMain.Location)=[forms]![frmSearch]![Location]));
****end snip ****
Pete