B
Brandon Johnson
Basically what I'm trying to do is take ALL the information from a
130,000 record table and send chunks of 50,000 to its own individual
excel documents. The problem lies when the record count in excel
exceeds the 50,000 mark after i send the information over. I don't
understand whats going on. If ANYONE coudl help that would be
EXCELLENT! Thank you in advance.
Here's an example of my sql statements:
For i = 1 To totalDocsNeeded
If i = 1 Then 'if i=1 then use simple
query to grab top 50000
Set tempT = CurrentDb.OpenRecordset("SELECT TOP 50000 * FROM
Results ORDER BY Branch ASC, ClientCode ASC;", dbOpenDynaset)
Else
If per * i >= 100 Then
'if at end of table just send rest of the
remaining to document. per is
the
' percentage of: 50000 / total records in the
table
Set tempT = CurrentDb.OpenRecordset("SELECT TOP 50000 *
FROM Results WHERE Branch IN (SELECT TOP 100 percent Branch FROM
Results ORDER BY Branch ASC) ORDER BY Branch DESC;", dbOpenDynaset)
Else 'Take 100000 records and take the last
50,000
Set tempT = CurrentDb.OpenRecordset("SELECT TOP 50000 *
FROM Results WHERE Branch IN (SELECT TOP " & 50000 * i & " Branch FROM
Results ORDER BY Branch ASC) ORDER BY Branch DESC;", dbOpenDynaset)
End If
End If
Next
130,000 record table and send chunks of 50,000 to its own individual
excel documents. The problem lies when the record count in excel
exceeds the 50,000 mark after i send the information over. I don't
understand whats going on. If ANYONE coudl help that would be
EXCELLENT! Thank you in advance.
Here's an example of my sql statements:
For i = 1 To totalDocsNeeded
If i = 1 Then 'if i=1 then use simple
query to grab top 50000
Set tempT = CurrentDb.OpenRecordset("SELECT TOP 50000 * FROM
Results ORDER BY Branch ASC, ClientCode ASC;", dbOpenDynaset)
Else
If per * i >= 100 Then
'if at end of table just send rest of the
remaining to document. per is
the
' percentage of: 50000 / total records in the
table
Set tempT = CurrentDb.OpenRecordset("SELECT TOP 50000 *
FROM Results WHERE Branch IN (SELECT TOP 100 percent Branch FROM
Results ORDER BY Branch ASC) ORDER BY Branch DESC;", dbOpenDynaset)
Else 'Take 100000 records and take the last
50,000
Set tempT = CurrentDb.OpenRecordset("SELECT TOP 50000 *
FROM Results WHERE Branch IN (SELECT TOP " & 50000 * i & " Branch FROM
Results ORDER BY Branch ASC) ORDER BY Branch DESC;", dbOpenDynaset)
End If
End If
Next