export more than 65000 records to excel from access table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • trtaan
    New Member
    • Feb 2008
    • 1

    export more than 65000 records to excel from access table

    Hi all,
    This is trtaan.
    I wanted to export around 300000 records that are present in my MS Access 2003 version table to excelsheet version8.
    I had written a code to export to multiple sheets in one workbook, but i failed to export the continous records.
    The code is exporting only the first 65536 records to multiple sheets.
    I want to find a way for this.
    --I tried to include an auto number field to my table but it was not successful.
    --I tried to give range to export but it is not supported.
    Code:
    Option Compare Database
        Dim i As Long
        Dim ren, old As String
        Dim n As Integer
        
    
    Private Sub exportt_Click()
        n = 1
        i = DCount("*", "s_table")
    MsgBox i
    
    
        If i > 65535 Then
            ren = "s_table" & n
            DoCmd.Rename ren, acTable, "s_table_tayi"
        Else
            ren = "s_table"
        End If
    
        While i > 0
            DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel8, ren, "D:\export65k.xls", -1
            i = i - 65535
            old = ren
            n = n + 1
            ren = "s_table" & n
            DoCmd.Rename ren, acTable, old
        Wend
        
        
    
    End Sub
    Please some one help me.......
Working...