G
Guest
Quoted below are two SQL strings from querydefs that are supposed to be
identical except that in one the grouping is on Factory, in the other it's on
Team. The first query runs fine. The second one, however, throws one of
those mysterious "sorry, we have to shut down, should we tell Microsoft about
it?" errors.
Team vs. Factory is the only obvious difference, but the only way I've found
to prevent the error from occurring is to take out the WHERE clause in the
second SQL string, after which it runs fine except that of course I am no
longer selecting for a particular year. (In both strings the WHERE is using
a value stored on a form which holds a numeric value signifying a particular
year, e.g., 2006.)
This is MADDENING! Anybody see what I'm missing?
THE SQL:
strSQL1 = "SELECT qryGetGraphDataPrequery.Factory,
qryGetGraphDataPrequery.WW, Sum(qryGetGraphDataPrequery.SchedSales) AS Goal,
Sum(qryGetGraphDataPrequery.ActualSales) AS Actual,
Sum(qryGetGraphDataPrequery.[P/D]) AS [Past Due]
FROM qryGetGraphDataPrequery
WHERE MYear = " & Me!txtThisYear & "
GROUP BY qryGetGraphDataPrequery.Factory, qryGetGraphDataPrequery.WW ORDER
BY qryGetGraphDataPrequery.Factory, qryGetGraphDataPrequery.WW;"
strSQL2 = "SELECT qryGetGraphDataPrequery.Team,
qryGetGraphDataPrequery.WW, Sum(qryGetGraphDataPrequery.SchedSales) AS Goal,
Sum(qryGetGraphDataPrequery.ActualSales) AS Actual,
Sum(qryGetGraphDataPrequery.[P/D]) AS [Past Due]
FROM qryGetGraphDataPrequery
WHERE MYear = " & Me!txtThisYear & "
GROUP BY qryGetGraphDataPrequery.Team, qryGetGraphDataPrequery.WW
ORDER BY qryGetGraphDataPrequery.Team, qryGetGraphDataPrequery.WW;"
identical except that in one the grouping is on Factory, in the other it's on
Team. The first query runs fine. The second one, however, throws one of
those mysterious "sorry, we have to shut down, should we tell Microsoft about
it?" errors.
Team vs. Factory is the only obvious difference, but the only way I've found
to prevent the error from occurring is to take out the WHERE clause in the
second SQL string, after which it runs fine except that of course I am no
longer selecting for a particular year. (In both strings the WHERE is using
a value stored on a form which holds a numeric value signifying a particular
year, e.g., 2006.)
This is MADDENING! Anybody see what I'm missing?
THE SQL:
strSQL1 = "SELECT qryGetGraphDataPrequery.Factory,
qryGetGraphDataPrequery.WW, Sum(qryGetGraphDataPrequery.SchedSales) AS Goal,
Sum(qryGetGraphDataPrequery.ActualSales) AS Actual,
Sum(qryGetGraphDataPrequery.[P/D]) AS [Past Due]
FROM qryGetGraphDataPrequery
WHERE MYear = " & Me!txtThisYear & "
GROUP BY qryGetGraphDataPrequery.Factory, qryGetGraphDataPrequery.WW ORDER
BY qryGetGraphDataPrequery.Factory, qryGetGraphDataPrequery.WW;"
strSQL2 = "SELECT qryGetGraphDataPrequery.Team,
qryGetGraphDataPrequery.WW, Sum(qryGetGraphDataPrequery.SchedSales) AS Goal,
Sum(qryGetGraphDataPrequery.ActualSales) AS Actual,
Sum(qryGetGraphDataPrequery.[P/D]) AS [Past Due]
FROM qryGetGraphDataPrequery
WHERE MYear = " & Me!txtThisYear & "
GROUP BY qryGetGraphDataPrequery.Team, qryGetGraphDataPrequery.WW
ORDER BY qryGetGraphDataPrequery.Team, qryGetGraphDataPrequery.WW;"