Well, I tried the IsNull function on the 3 SUM() values I was
calculating in my SELECT statement (on a LEFT OUTER JOIN QUERY),
and I STILL got another "cannot convert "" to a number" but this
time the error message was more direct, and pointed me to a DATE
field in my query, where I was SORTING AND GROUPING either by DAY
or MONTH (depending on what user selected on form).
In my QofQ, I'm not just reformating the integer SUM()
values, but also the date values. So, I applied the IsNull()
function to the DATE values in my main query. I still kept getting
errors. But after experimenting ((SQL Server BOL docs doesn't give
ISNULL() examples for DATE FIELDS, only NUMBER fields), I tried
putting the dates in SINGLE QUOTES in my IsNull() function, the
QUERY RAN. Then I wasn't sure WHAT date to enter, e.g., 1/1/1889 or
1/1/2001, etc.
Then, I discovered, after experimenting, that you cannot just
blindly enter ANY date when using IsNull in a date field,
especially if you are using CFGRAPH to chart the results by day.
You have to select a date within the date range the user selected,
so this means using the FORM.DATE (or URL.DATE) value from the
form. Here's the working example from my SELECT main query:
SELECT SUM(ISNULL(d.ttldb,0)) AS SumOfDB,
SUM(ISNULL(d.ttldbv,0)) AS SumOfDBV,
SUM(ISNULL(d.ttldbi,0)) AS SumOfDBI,
<CFIF '#url.reptype#' IS "DAILY">
ISNULL(d.depday, '#url.date1#') AS depday
<CFELSE>
month(ISNULL(d.depday, '#url.date2#')) AS TranMonth,
year(ISNULL(d.depday, '#url.date2#')) AS TranYear
</CFIF>
Then I discovered that whatever date was used in the URL.DATE
field (in my case it would be one of the two date field from the
form, and depended on whether you coded DATE1 or DATE2, the chart
would always show ZERO values for that date. So I tried putting the
IsNull() date values in the GROUP BY and ORDER BY statements, e.g.,
<CFIF '#url.reptype#' IS "DAILY">
GROUP BY ISNULL(d.depday, '#url.date1#')
ORDER BY ISNULL(d.depday, '#url.date1#') DESC
<CFELSE>
GROUP BY year(ISNULL(d.depday, '#url.date2#')),
month(ISNULL(d.depday, '#url.date2#'))
ORDER BY year(ISNULL(d.depday, '#url.date2#')),
month(ISNULL(d.depday, '#url.date2#'))
</CFIF>
And this worked. The report ran just fine, and the chart
charted every value correctly.
I guess you have to learn all the little "quirks" about CF7
and how it's QofQ and chart programs work. But so far, so good.
Thank you all for your help. Now I've got to update other old
CF5 programs that are returning errors when there are null values
from my LEFT OUTER JOIN queries. Will take some time, but at least
I know how to do it. Thanks to your help.
I really appreciate your time and efforts to help with this
issue.
Gary