Link to home
Start Free TrialLog in
Avatar of _Hector
_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]
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

Can you post the SQL of the query?
Avatar of _Hector
_Hector

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]![Master Form]![Division]) AND (([REPORT DBASE].ICCLS)=[Forms]![Master Form]![Class]))
ORDER BY [REPORT DBASE].IFITEM;
ASKER CERTIFIED SOLUTION
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Try to put or instead of and


 
WHERE ((([REPORT DBASE].ICDIV)=[Forms]![Master Form]![Division]) or (([REPORT DBASE].ICCLS)=[Forms]![Master Form]![Class]))

Open in new window

theknee,

The issues with switching to OR is that if both parameters are left blank, no records are returned.


JeffCoachman
Avatar of _Hector

ASKER

Sweet!
Thank you.
Thanks _Hector!

;-)

Jeff