dsurls
Programmer
- May 20, 2003
- 7
I have a fairly complex crosstab query that is created via DAO code in a VB6 app. The query is saved in a Jet 4.0 database, and when I run it directly from within Access 2003 it runs fine; but when I run it from within the VB6 app, I get an Application Error which crashes the IDE:
vb6.exe - Application Error
The instruction at "0x7c910de3" referenced memory at "0xfffffff8". The memory could not be "read".
It also crashes the compiled application if I run it outside the IDE.
The SQL for the query is below. Note that the PIVOT clause is used to specify the order of the columns, which are a concatenation of two fields in a related table. The columns are specified explicitly using an "IN ()" clause. I have a suspicion that the length of that clause is causing the problem (smaller lists of columns work fine). If so, is there a way to specify the PIVOT columns using a subquery rather than explicitly listing them one by one? Do you think that could indeed be the culprit, and if not, what else could it be?
Thanks very much for your help!!
David
vb6.exe - Application Error
The instruction at "0x7c910de3" referenced memory at "0xfffffff8". The memory could not be "read".
It also crashes the compiled application if I run it outside the IDE.
The SQL for the query is below. Note that the PIVOT clause is used to specify the order of the columns, which are a concatenation of two fields in a related table. The columns are specified explicitly using an "IN ()" clause. I have a suspicion that the length of that clause is causing the problem (smaller lists of columns work fine). If so, is there a way to specify the PIVOT columns using a subquery rather than explicitly listing them one by one? Do you think that could indeed be the culprit, and if not, what else could it be?
Thanks very much for your help!!
David
Code:
TRANSFORM Sum(SumValue) AS [Sum]
SELECT [Date]
FROM (SELECT Sum(SourceData.[Data Value])/Sum(SourceData.[Applied Value]) AS SumValue, [Date].Order AS [DateOrder], SourceData.[Date], SourceData.[Scenario], SourceData.[Draw]
FROM (((SourceData LEFT JOIN [Date] ON SourceData.[Date] = [Date].[Date]) LEFT JOIN [Scenario] ON [SourceData].[Scenario] = [Scenario].[Scenario]) LEFT JOIN [Draw] ON [SourceData].[Draw] = [Draw].[Draw])
WHERE [SourceData].[Data Item] = 'Total System Cost'
GROUP BY SourceData.[Date], [Date].Order, SourceData.[Scenario], SourceData.[Draw]) AS BaseData
GROUP BY [DateOrder], [Date]
ORDER BY [DateOrder]
PIVOT Left([Scenario] & ': ' & [Draw], 64)
IN ("Base Case: 0" ,"Supply Collar - MC: 0" ,"Supply Collar - MC: 1" ,
..., (a total of about 202 columns)
"Supply Collar - MC: 199" ,"Supply Collar - MC: 200");