sql - Only Perform Group By When Combo Box is Not Empty -
i've solved problem before. unfortunately, i'm having hardest time remembering solution.
i have 3 combo boxes, 1 of (quarter) user can choose leave empty. 3 combo boxes attached fields in query. each field setup perform group (case manager, fiscal year, quarter). if combo box quarter not empty, query filters correctly. performs group case manager, fiscal year, , quarter.
when combo box quarter left empty, query should group case manager , fiscal year. performs group on quarter well.
this sql query:
select tblcm.cm, tblfy.fiscalyear, tblqtr.quarter, count(tbldata.casenum) countofcasenum, avg(tbldata.[daystonotifysite-completecalc]) [avgofdaystonotifysite-completecalc], avg(tbldata.[days contact site]) [avgofdays contact site], avg(tbldata.daystoholdmedafterorder) avgofdaystoholdmedafterorder, avg(tbldata.daystoholdmed) avgofdaystoholdmed, avg(tbldata.daystoissuedgodec) avgofdaystoissuedgodec, avg(tbldata.daystocloseafterdecrecdbynrc) avgofdaystocloseafterdecrecdbynrc, avg(tbldata.daystoclosecase) avgofdaystoclosecase tblqtr inner join (tblfy inner join (tblcm inner join tbldata on tblcm.cm = tbldata.[cmnames-corrected]) on tblfy.fiscalyear = tbldata.fiscalyearfilingform) on tblqtr.quarter = tbldata.qtrfilingformrec (((tbldata.type)<>"dra")) group tblcm.cm, tblfy.fiscalyear, tblqtr.quarter having (((tblcm.cm)<>"doe, john" , (tblcm.cm)=[forms]! [frmindividualgoals]![cbocm]) , ((tblfy.fiscalyear)=[forms]![frmindividualgoals]![cbofy]) , ((tblqtr.quarter)=iif([forms]![frmindividualgoals]![cboqtr]<>'',[forms]![frmindividualgoals]![cboqtr]))) or (((tblcm.cm)<>"doe, john" , (tblcm.cm)=[forms]![frmindividualgoals]![cbocm]) , ((tblfy.fiscalyear)=[forms]![frmindividualgoals]![cbofy]) , (([forms]![frmindividualgoals]![cboqtr]) null));
the select statement fine. may wrong. but, believe problem in last , statement. but, provided of sql reference.
currently i'm using command button open query after selections made in combo boxes test results.
thank can provide.
Comments
Post a Comment