Getting "Numeric Value Out of Range" Error when Trying to Change Conditions in Select Statement to use Parameters

lmpena484

New Member
Joined
Jul 12, 2018
Messages
1
I am using the below Select statement, which works fine. However, when I change the values below in Red to ? as is done in the WHERE clause toward the end of the statement in order to use parameters defined in specific cells in a worksheet, I get a "Numeric Value Out of Range" error. I do not know how to fix this as the cells I'm referencing for the parameters are exactly the same as those I'm referencing for the CDFYR parameters further below in the WHERE clause (which work fine). In other words, I have the value 2017 loaded into cell B1 and 2018 loaded into cell B2. Cells B1 and B2 are what I'm trying to use as my reference points for all of the CDFYR parameters.

SELECT DISTINCT
CDPAYEE AS "Payee #",
PAYEENAME AS "Payee Name",
MMNAME AS "Manufacturer Name",
ECHECK AS "Lead Name",
SUM ( CASE
WHEN CDFYR = 2017 THEN CDBASE
ELSE 0
END ) AS "Last FYTD COGS",
SUM ( CASE
WHEN CDFYR = 2018 THEN CDBASE
ELSE 0
END ) AS "This FYTD COGS"
FROM
SALESQRY.CSTQRYD CSTQRYD
LEFT OUTER JOIN QS36F.PAYEEVTL PAYEEVTL
ON
CSTQRYD.CDPAYEE = PAYEEVTL.PAYEE#
LEFT OUTER JOIN QS36F.PAYEEMANU PAYEEMANU
ON
PAYEEVTL.PAYEE# = PAYEEMANU.PPAYEE
LEFT OUTER JOIN QS36F.MANUFACT MANUFACT
ON
PAYEEMANU.PMANU# = MANUFACT.MMANU#
LEFT OUTER JOIN QS36F.EMPLQ EMPLQ
ON
PAYEEVTL.LEADID = EMPLQ.EEMPNUM

WHERE
CDFYR BETWEEN ? AND ?
AND CDPER BETWEEN ? AND ?


GROUP BY
CDPAYEE,
PAYEENAME,
MMNAME,
ECHECK
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Forum statistics

Threads
1,223,902
Messages
6,175,278
Members
452,629
Latest member
SahilPolekar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top