I've written a routine that is suppose to select all the rows based on the criteria add a new record from an array if the information is not already in the database or else update the records found.
Here's the code with a .find problem. I need to find a specific value in the specified field in the recordset and update it or add a new record.
strSQL = "SELECT * FROM dbo_Accs WHERE WorkstationId = '" & Trim(aryAccs(0, 0)) & "'"
Set rstAudt = New ADODB.Recordset
rstAudt.Open strSQL, objW2kConn, 3, 3
For intCounter = LBound(aryAccs, 2) To UBound(aryAccs, 2)
With rstAudt
If .RecordCount < 1 Then
.AddNew
.Fields("WorkstationId"
= Trim(aryAccs(0, intCounter))
.Fields("MDBFiles"
= Trim(aryAccs(1, intCounter))
Else
.Find "MDBFiles = '" & Trim(aryAccs(1, intCounter))& " '", , , 0
If .EOF Then
.AddNew
.Fields("WorkstationId"
= Trim(aryAccs(0, intCounter))
.Fields("MDBFiles"
= Trim(aryAccs(1, intCounter))
Else
.Fields("MDBFiles"
= Trim(aryAccs(1, intCounter))
If Not .EOF Then
.MoveNext
End If
End If
.Update
End With
Next
Here's the code with a .find problem. I need to find a specific value in the specified field in the recordset and update it or add a new record.
strSQL = "SELECT * FROM dbo_Accs WHERE WorkstationId = '" & Trim(aryAccs(0, 0)) & "'"
Set rstAudt = New ADODB.Recordset
rstAudt.Open strSQL, objW2kConn, 3, 3
For intCounter = LBound(aryAccs, 2) To UBound(aryAccs, 2)
With rstAudt
If .RecordCount < 1 Then
.AddNew
.Fields("WorkstationId"
.Fields("MDBFiles"
Else
.Find "MDBFiles = '" & Trim(aryAccs(1, intCounter))& " '", , , 0
If .EOF Then
.AddNew
.Fields("WorkstationId"
.Fields("MDBFiles"
Else
.Fields("MDBFiles"
If Not .EOF Then
.MoveNext
End If
End If
.Update
End With
Next