T
Tcs
I have a variable number of records in a table I use to build my pass-thru SQL
statement. I find out how many rows there are, and divide by 100, building my
statement using only 100 rows at a time. (To keep the overall size of the
statement within limits.) Then I perform a loop for how many times I need,
i.e., 706 rows = 8 loops, 701 rows = 8 loops, 700 rows = 7 loops, etc. From
within this loop I call a function which loops the 100 necessary to get the rows
and build the statement. All this actually works...BUT...not always.
I seem to get the:
Error # 3021 was generated by DAO.Field
No current record.
error intermittently. It would seem I still don't quite understand when rs.EOF
is true. I've done this kind of thing before, many times, although NOT in VBA.
Here's my code, any suggestions/corrections would be greatly appreciated.
If Not rs.EOF Then
If rs.EOF Then
Exit Function
End If
rs.MoveNext
strSQLwhere1a = _
"((b.UTCSID=" & rs![CustID] & ") AND (b.UTLCID=" & rs![LocID] & "))"
MsgBox strSQLwhere1a, , "strSQLwhere1a - " & Date & " - " & Time
Else
Exit Function
End If
Do While Not rs.EOF
If rs.EOF Then
Exit Function
End If
For intLoop2 = 1 To 99
' MsgBox "(" & intLoop1 & ")", , "intLoop1 - " & Date & " - " & Time
' MsgBox "(" & intLoop2 & ")", , "intLoop2 - " & Date & " - " & Time
If intLoop1 > 6 Then
' MsgBox "(" & intLoop1 & ")", , "intLoop1 - " & Date & " - " & Time
' MsgBox "(" & intLoop2 & ")", , "intLoop2 - " & Date & " - " & Time
End If
rs.MoveNext
strSQLwhere1a = strSQLwhere1a & _
" OR ((b.UTCSID=" & rs![CustID] & ") AND (b.UTLCID=" & rs![LocID] & "))"
' MsgBox strSQLwhere1a, , "strSQLwhere1a - " & Date & " - " & Time
DoEvents
Next intLoop2
Exit Do
Loop
Thanks in advance,
Tom
statement. I find out how many rows there are, and divide by 100, building my
statement using only 100 rows at a time. (To keep the overall size of the
statement within limits.) Then I perform a loop for how many times I need,
i.e., 706 rows = 8 loops, 701 rows = 8 loops, 700 rows = 7 loops, etc. From
within this loop I call a function which loops the 100 necessary to get the rows
and build the statement. All this actually works...BUT...not always.
I seem to get the:
Error # 3021 was generated by DAO.Field
No current record.
error intermittently. It would seem I still don't quite understand when rs.EOF
is true. I've done this kind of thing before, many times, although NOT in VBA.
Here's my code, any suggestions/corrections would be greatly appreciated.
If Not rs.EOF Then
If rs.EOF Then
Exit Function
End If
rs.MoveNext
strSQLwhere1a = _
"((b.UTCSID=" & rs![CustID] & ") AND (b.UTLCID=" & rs![LocID] & "))"
MsgBox strSQLwhere1a, , "strSQLwhere1a - " & Date & " - " & Time
Else
Exit Function
End If
Do While Not rs.EOF
If rs.EOF Then
Exit Function
End If
For intLoop2 = 1 To 99
' MsgBox "(" & intLoop1 & ")", , "intLoop1 - " & Date & " - " & Time
' MsgBox "(" & intLoop2 & ")", , "intLoop2 - " & Date & " - " & Time
If intLoop1 > 6 Then
' MsgBox "(" & intLoop1 & ")", , "intLoop1 - " & Date & " - " & Time
' MsgBox "(" & intLoop2 & ")", , "intLoop2 - " & Date & " - " & Time
End If
rs.MoveNext
strSQLwhere1a = strSQLwhere1a & _
" OR ((b.UTCSID=" & rs![CustID] & ") AND (b.UTLCID=" & rs![LocID] & "))"
' MsgBox strSQLwhere1a, , "strSQLwhere1a - " & Date & " - " & Time
DoEvents
Next intLoop2
Exit Do
Loop
Thanks in advance,
Tom