T
tsison7
I have a report which draws from the query below (simplified). Basically, I
want it to either filter for all customers - where getmyvariable() = 99 - or
for a specific account manager only. This is determined by which command
button calls on the report which correspondingly sets the getmyvariable()
function to either 99 for all or for the specific account manager.
My problem is the query below will only work when it is called for a
specific account manager. I even tried putting the individual conditions in
to check if they are correct and they work (ie. [tblAcctMgr].[AcctMgrID]<>99)
by itself generates the correct results.
Your hellp is appreciated....
SELECT qrySCS.[Cust ID], tblCustomers.Customer, Sum(qrySCS.Qty) AS SumOfQty
FROM tblAcctMgr INNER JOIN (qrySCS INNER JOIN tblCustomers ON qrySCS.[Cust
ID] = tblCustomers.PSCustNo) ON tblAcctMgr.AcctMgrID = tblCustomers.AcctMgrID
WHERE
(((tblAcctMgr.AcctMgrID)=IIf(getmyvariable()=99,[tblAcctMgr].[AcctMgrID]<>99,getmyvariable())))
GROUP BY qrySCS.[Cust ID], tblCustomers.Customer;
want it to either filter for all customers - where getmyvariable() = 99 - or
for a specific account manager only. This is determined by which command
button calls on the report which correspondingly sets the getmyvariable()
function to either 99 for all or for the specific account manager.
My problem is the query below will only work when it is called for a
specific account manager. I even tried putting the individual conditions in
to check if they are correct and they work (ie. [tblAcctMgr].[AcctMgrID]<>99)
by itself generates the correct results.
Your hellp is appreciated....
SELECT qrySCS.[Cust ID], tblCustomers.Customer, Sum(qrySCS.Qty) AS SumOfQty
FROM tblAcctMgr INNER JOIN (qrySCS INNER JOIN tblCustomers ON qrySCS.[Cust
ID] = tblCustomers.PSCustNo) ON tblAcctMgr.AcctMgrID = tblCustomers.AcctMgrID
WHERE
(((tblAcctMgr.AcctMgrID)=IIf(getmyvariable()=99,[tblAcctMgr].[AcctMgrID]<>99,getmyvariable())))
GROUP BY qrySCS.[Cust ID], tblCustomers.Customer;