User Parameter to NOT exclude NULL fields

  • Thread starter Thread starter Lynne Waldron
  • Start date Start date
L

Lynne Waldron

SELECT MFGNAME, MFGCODE, PART_NO
FROM tblTruckMasterPartList
WHERE
(((MFGNAME) Like "*" & [Which Manufacturer? {Enter for
All}] & "*")
AND
((PART_NO) Like "*" & [Which Part Number? {Enter for
All}] & "*"));

The intent is to be able to have users enter a fragment
for either manufacturer or part number or to press enter
to return all. If they press enter on both any records
with NULL values in either field are excluded. Is there a
better way to write this query?

Thanks so much,

Lynne L. Waldron
 
Is there a better way to write this query?

Perhaps: try

SELECT MFGNAME, MFGCODE, PART_NO
FROM tblTruckMasterPartList
WHERE
(((MFGNAME) = [Which Manufacturer? {Enter for All}]
OR [Which Manufacturer? {Enter for All}] IS NULL)
AND
((PART_NO) = [Which Part Number? {Enter for All}]
OR [Which Part Number? {Enter for All}] IS NULL));
 
Yes thanks, this works!
-----Original Message-----
Is there a better way to write this query?

Perhaps: try

SELECT MFGNAME, MFGCODE, PART_NO
FROM tblTruckMasterPartList
WHERE
(((MFGNAME) = [Which Manufacturer? {Enter for All}]
OR [Which Manufacturer? {Enter for All}] IS NULL)
AND
((PART_NO) = [Which Part Number? {Enter for All}]
OR [Which Part Number? {Enter for All}] IS NULL));



.
 
Back
Top