|
|
Question : How to resolve: There are too many rows to output, based on the limitation specified by the output format or by Microsoft Office Access ?
|
|
I create an Access Report with the following code in my Access application to send the report output to an Excel file: The reason I use the report is to create sub-totals. There are 18,500 rows to output and I guess the limit is 16,536. I get the message:
There are too many rows to output, based on the limitation specified by the output format or by Microsoft Office Access.
Do you know how I can resolve the error ? ------------------------------------------------- Set com = New ADODB.Command With com .CommandType = adCmdStoredProc .CommandText = "dbo.procDetailRangeRpt3YRPlus" Set .ActiveConnection = cn .Execute End With intReport = intYearSP + 1 ExportedFile = "C:\UDL\DTLRANGE" & "_" & intReport & "_" & Format(Now, "mmddhhnnss") & ".XLS" DoCmd.OutputTo acOutputReport, "RptDetailReport", acFormatXLS, ExportedFile Beep MsgBox "Detail Range Report has been exported to Excel", vbOKOnly, "" If isFileExist(ExportedFile) Then StartDocDetail ExportedFile
--------------------------------------------------------------------------------------------------------------------------------------------- CREATE PROCEDURE procDetailRangeRpt3YRPlus AS
If Exists(SELECT * FROM dbo.SYSOBJECTS WHERE NAME = ' tblDtlRange' AND TYPE = 'U') DROP TABLE tblDtlRange
SELECT C.OfficeNumber, C.CustomerNumber, C.ResStateCode, C.ResCountryCode, C.CitizenCode, C.DateLost, C.DateOfBirth, C.SSN, C.TaxId, C.FixedFieldInd, C.FirstName, C.MiddleInitial, C.LastName, C.StreetAddr1, C.StreetAddr2, C.City, C.State, C.Zip, C.Country, C.RedFlag, tblMthRanges.MthFrom, tblMthRanges.MthTitle, --CASE WHEN P.MarketValue IS NULL THEN P.CashBalance ELSE P.MarketValue END AS [Acct Value], Sum(isnull(MarketValue,0)+isnull(CashBalance,0)) AS AcctValue, CONVERT(char(10), GETDATE() - Day(GETDATE()) + 1, 121) AS DFrom, CONVERT(char(10), DATEADD(Month, -[MthTo] + 1, GETDATE() - Day(GETDATE()) + 1), 121) AS DateFromC, tblMthRanges.MthTo, CONVERT(char(10),DATEADD(MONTH, -MthFrom, CONVERT(varchar(8), GETDATE(), 102)+ '01'), 121) AS DateToC INTO tblDtlRange FROM tblMthRanges, tblCustomers As C INNER JOIN tblProducts As P ON C.CustomerNumber=P.CustomerNumber AND C.OfficeNumber=P.OfficeNumber WHERE (((DATEDIFF(M, [DateLost], DATEADD(DD, (DATEPART(DD, GETDATE()) -1) * -1, GETDATE())) >= [MthFrom])) AND ((DateDiff(M,[DateLost],DATEADD(DD, (DATEPART(DD, GETDATE()) -1) * -1, GETDATE())) < [MthTo]))) AND [MthFrom] = 36 AND [MthTo] = 1000 GROUP BY tblMthRanges.MthFrom, tblMthRanges.MthTitle, C.OfficeNumber, C.CustomerNumber, DATEADD(M, [MthTo] * -1, DATEADD(DD, (DATEPART(DD, GETDATE()) - 1) * -1, GETDATE())), tblMthRanges.MthTo, DATEADD(M,[MthFrom]*-1,DATEADD(DD, DATEPART(DD, GETDATE()) * -1, GETDATE())),C.ResStateCode, C.ResCountryCode, C.CitizenCode, C.DateLost, C.DateOfBirth, C.SSN, C.TaxId, C.FixedFieldInd, C.FirstName, C.MiddleInitial, C.LastName, C.StreetAddr1, C.StreetAddr2, C.City, C.State, C.Zip, C.Country, C.RedFlag
If Exists(SELECT * FROM dbo.SYSOBJECTS WHERE NAME = ' tblRCustR' AND TYPE = 'U') DROP TABLE tblRCustR
SELECT tblDtlRange.OfficeNumber, tblDtlRange.CustomerNumber, tblDtlRange.AcctValue, tblDollarRanges.DollarTitle, tblDollarRanges.DollarFrom INTO tblRCustR FROM tblDtlRange INNER JOIN tblDollarRanges ON tblDtlRange.AcctValue BETWEEN tblDollarRanges.DollarFrom AND tblDollarRanges.DollarTo WHERE tblDtlRange.AcctValue > 9.00 ORDER BY AcctValue DESC
SELECT tblRCustR.OfficeNumber, tblRCustR.CustomerNumber, tblRCustR.AcctValue, tblRCustR.DollarTitle
FROM tblRCustR ORDER BY case when DollarTitle = 'WITH LESS THAN $1K ASSETS' then 6 when DollarTitle = 'WITH $1K TO LESS THAN $10 K ASSETS' then 5 when DollarTitle = 'WITH $10K TO LESS THAN $25 K ASSETS' then 4 when DollarTitle = 'WITH $25K TO LESS THAN $50 K ASSETS' then 3 when DollarTitle = 'WITH $50K TO LESS THAN $100 K ASSETS' then 2 when DollarTitle = 'WITH $100K + ASSETS' then 1 end , OfficeNumber, CustomerNumber GO
|
Answer : How to resolve: There are too many rows to output, based on the limitation specified by the output format or by Microsoft Office Access ?
|
|
The "runcommand acCmdOutputToExcel" would be two lines
DoCmd.SelectObject acReport, strName, True 'False if the report is open DoCmd.RunCommand acCmdOutputToExcel
It was created for A2k version so it may not have the 18k limit. I used it for 14K records.
|
|
|
|
|