End of records in a database
Dim cn As New ADODB.Connection
Dim recSet As New ADODB.Recordset
Dim ConnectionString As String
Dim strSQL1 As String, strSQL2 As String
Dim i As Integer
Dim lvItem As ListItem
Dim sa As String
Dim sAssetFound As String
Dim j As Integer
On Error GoTo ErrorHandler2
Screen.MousePointer = vbHourglass
'Define connection string to connect to the database
ConnectionString = "PROVIDER=MSDASQL;dsn=Calibration Data;uid=LogInOut;pwd=loginout;"
cn.ConnectionString = ConnectionString
cn.Open
j = 1
sAssetFound = "1" 'just something to start
If cn.State = adStateOpen Then
If cn.State = adStateOpen Then
Do Until sAllTheModels(j) = ""
Do Until sAssetFound = ""
On Error GoTo GetNextModel
strSQL1 = "SELECT * FROM mt.Inventory A " & _
"WHERE A.I4203='" + sAllTheModels(j) + "'" & _
"AND A.I4230=0"
recSet.Open strSQL1, cn, adOpenDynamic, adLockOptimistic 'open for read / write using SQL string # 3
sAssetFound = CStr(recSet.Fields("I4201"))
recSet.Fields("I4254") = sAllTheData(j) 'change the Cal lab Std cal time
recSet.Fields("I4230") = 1 'change the integer
recSet.Update 'now update the database
recSet.Close 'close
Loop
GetNextModel: DoEvents
recSet.Close 'close ?
Err.Clear
j = j + 1
Loop
Else
MsgBox "The connection could not be made!", vbCritical, "Error"
GoTo ExitHandler2
End If
My problem is on the line: recSet.Open..... If I am at the end of the records I just get an error and jump out. What I need is a way to tell if I am at the end before this so that I can continue the first do loop.

