_Hector
asked on
Filtered Query from a form value
I have a form that has 2 fields Division and class that if a value is populated in each my query is filtered by this criteria. However I must specify a value in both these fields or blank records are returned. How can I modify the code so that if any of the 2 fields are not populated I still see all the records.
TIA
[Forms]![Master Form]![Division]
[Forms]![Master Form]![Class]
TIA
[Forms]![Master Form]![Division]
[Forms]![Master Form]![Class]
Can you post the SQL of the query?
ASKER
Sure,
SELECT [REPORT DBASE].IFITEM, [REPORT DBASE].ICDSC1, [REPORT DBASE].IFQOH, [REPORT DBASE].IFQPO, [REPORT DBASE].IFQBO, [REPORT DBASE].IFAVU, [REPORT DBASE].IFTRAN, [REPORT DBASE].IFQBT, [REPORT DBASE].AVGX6, [REPORT DBASE].IFSMTD, [REPORT DBASE].ICMAST, [REPORT DBASE].ICDIV, [REPORT DBASE].ICCLS
FROM [REPORT DBASE]
WHERE ((([REPORT DBASE].ICDIV)=[Forms]![Mas ter Form]![Division]) AND (([REPORT DBASE].ICCLS)=[Forms]![Mas ter Form]![Class]))
ORDER BY [REPORT DBASE].IFITEM;
SELECT [REPORT DBASE].IFITEM, [REPORT DBASE].ICDSC1, [REPORT DBASE].IFQOH, [REPORT DBASE].IFQPO, [REPORT DBASE].IFQBO, [REPORT DBASE].IFAVU, [REPORT DBASE].IFTRAN, [REPORT DBASE].IFQBT, [REPORT DBASE].AVGX6, [REPORT DBASE].IFSMTD, [REPORT DBASE].ICMAST, [REPORT DBASE].ICDIV, [REPORT DBASE].ICCLS
FROM [REPORT DBASE]
WHERE ((([REPORT DBASE].ICDIV)=[Forms]![Mas
ORDER BY [REPORT DBASE].IFITEM;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Try to put or instead of and
WHERE ((([REPORT DBASE].ICDIV)=[Forms]![Master Form]![Division]) or (([REPORT DBASE].ICCLS)=[Forms]![Master Form]![Class]))
theknee,
The issues with switching to OR is that if both parameters are left blank, no records are returned.
JeffCoachman
The issues with switching to OR is that if both parameters are left blank, no records are returned.
JeffCoachman
ASKER
Sweet!
Thank you.
Thank you.
Thanks _Hector!
;-)
Jeff
;-)
Jeff