The problem as far as I can tell is not with the data. In fact, I have the exact same code working just fine with an Access database. I have tried different sets of data, and it always does the same thing. Around record 1970, it bombs out and gives the error message I mentioned above. It is almost like there is some sort of limit to how many times you can connect to the database. I have spent hours trying to figure out what is going on here.
Here is the code below:
Dim cnn As ADODB.Connection
Call GetCnn(cnn)
Dim strqry As String
'INSERT RECORD INTO CALL LIST
Dim rsAction As ADODB.Recordset
Set rsAction = New ADODB.Recordset
rsAction.ActiveConnection = cnn
DIM CtrNumberToPull As Double
Dim branch1 As Double
Dim branch2 As Double
branch1 = rsBranches("Branch")
branch2 = branch1
Dim intFile As Integer
intFile = FreeFile
Open CurDir & "\ErrorLog.Txt" For Append Shared As intFile
While Not rsBranches.EOF
CtrNumberToPull = rsBranches("NumberToPull")
While rsBranches("bank") = rsData("bank") And rsBranches ("Branch") = rsData("branch")
'INSERT INTO CALL LIST WHILE NUMBER TO PULL IS GREATER THAN 0
If CtrNumberToPull > 0 Then
strqry = "INSERT INTO tbl_CallList ([TransNum], [Bank], [Branch], [Phone], [OfficialBranchName], [Address], [City], [Date_1]) " & _
" VALUES (" & rsData("TransNum") & " , '" & rsData("Bank") & "', " & _
" " & rsData("Branch") & ", '" & rsData("Phone") & "', " & _
" '" & Replace(rsData("OfficialBranchName"), "'", "''") & "','" & Replace(rsData("Address"), "'", "''") & "', " & _
" '" & Replace(rsData("City"), "'", "''") & "', '" & rsData("Date_1") & "')"
rsAction.Open (strqry)
End If
Write #intFile, rsData("bank"), rsData("Branch")
rsData.MoveNext
If rsData.EOF Then
GoTo here
End If
CtrNumberToPull = CtrNumberToPull - 1
Wend
rsBranches.MoveNext
Wend
here:
nikotromus
|