A
alex
Recordset too large?
Hello,
Using Access ’03…
I have some code below that’s in a form module and opens a recordset
based on what’s on the form.
The code works very well, but I’m now running into problems with large
recordsets (> 1000 or so). I get an error on rst.MoveNext (after 1151
records have been processed—inserted into a table). The error is: ODBC
—call failed ‘3146’. Is there a limit to how many records can be
processed by a DAO recordset?
Code:
‘other sql strings above
Dim strCareOf As String 'care of query
If Me.ckCareOf = True Then
strCareOf = _
"SELECT 'CareOf’ as Source, " & _
"File_Number " & _
"FROM MasterFile " & _
"WHERE Care_Of Like """ & strFName & " " & strLName & """ " & _
"Union All " & _
"SELECT ‘CareOf' as Source, " & _
"File_Number " & _
"FROM MasterFile2" & _
"WHERE Care_Of Like """ & strFName & " " & strLName & """ " & _
"Union All "
'Debug.Print strCareOf
End If
Dim strSQL As String
strSQL = strTip & strNol & strPer & strMer & strCareOf
strSQL = Left(strSQL, Len(Trim(strSQL)) - 9) 'remove 'Union All'
from end of string
'Debug.Print strSQL
' Open pointer to current database
Set dbs = CurrentDb()
' Create recordset based on SQL
Set rst = dbs.OpenRecordset(strSQL) ', dbOpenDynaset) 'http://
allenbrowne.com/ser-29.html
Do While Not rst.EOF 'loop through recordset
'sql string must be inside loop to refresh file number
Dim strInsert As String 'insert person LName, FName, and DOB
strInsert = _
"Insert Into " & conTable & " " _
& "Select " _
& " '" & strLName & "' as LName, " _
& " '" & strFName & "' as FName, " _
& " '" & strDOB & "' as DOB, " _
& " '" & rst![Source] & "' as Source, " _
& " '" & rst![File_Number] & "' as File_Number "
'Debug.Print rst![File_Number] 'test results of union query
CurrentDb.Execute (strInsert) 'insert results into table
rst.MoveNext
Loop
‘end of code
One thing to probably look at is the recordset type…I had dynaset, but
it made no difference. I do not need to manipulate the data, just
grab it and insert into a table.
Also, the ‘data’ is coming/retrieved from a linked table on a sql
server back-end.
Thanks for any help/advice
alex
Hello,
Using Access ’03…
I have some code below that’s in a form module and opens a recordset
based on what’s on the form.
The code works very well, but I’m now running into problems with large
recordsets (> 1000 or so). I get an error on rst.MoveNext (after 1151
records have been processed—inserted into a table). The error is: ODBC
—call failed ‘3146’. Is there a limit to how many records can be
processed by a DAO recordset?
Code:
‘other sql strings above
Dim strCareOf As String 'care of query
If Me.ckCareOf = True Then
strCareOf = _
"SELECT 'CareOf’ as Source, " & _
"File_Number " & _
"FROM MasterFile " & _
"WHERE Care_Of Like """ & strFName & " " & strLName & """ " & _
"Union All " & _
"SELECT ‘CareOf' as Source, " & _
"File_Number " & _
"FROM MasterFile2" & _
"WHERE Care_Of Like """ & strFName & " " & strLName & """ " & _
"Union All "
'Debug.Print strCareOf
End If
Dim strSQL As String
strSQL = strTip & strNol & strPer & strMer & strCareOf
strSQL = Left(strSQL, Len(Trim(strSQL)) - 9) 'remove 'Union All'
from end of string
'Debug.Print strSQL
' Open pointer to current database
Set dbs = CurrentDb()
' Create recordset based on SQL
Set rst = dbs.OpenRecordset(strSQL) ', dbOpenDynaset) 'http://
allenbrowne.com/ser-29.html
Do While Not rst.EOF 'loop through recordset
'sql string must be inside loop to refresh file number
Dim strInsert As String 'insert person LName, FName, and DOB
strInsert = _
"Insert Into " & conTable & " " _
& "Select " _
& " '" & strLName & "' as LName, " _
& " '" & strFName & "' as FName, " _
& " '" & strDOB & "' as DOB, " _
& " '" & rst![Source] & "' as Source, " _
& " '" & rst![File_Number] & "' as File_Number "
'Debug.Print rst![File_Number] 'test results of union query
CurrentDb.Execute (strInsert) 'insert results into table
rst.MoveNext
Loop
‘end of code
One thing to probably look at is the recordset type…I had dynaset, but
it made no difference. I do not need to manipulate the data, just
grab it and insert into a table.
Also, the ‘data’ is coming/retrieved from a linked table on a sql
server back-end.
Thanks for any help/advice
alex