User Parameter to NOT exclude NULL fields

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
 
J

John Vinson

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));
 
L

Lynne L. Waldron

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));



.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top