Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HELP!!! How to rst.Update or rst.Addnew

Status
Not open for further replies.

hdougl1

Programmer
Dec 6, 2000
54
US
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(&quot;WorkstationId&quot;) = Trim(aryAccs(0, intCounter))
.Fields(&quot;MDBFiles&quot;) = Trim(aryAccs(1, intCounter))
Else
.Find &quot;MDBFiles = '&quot; & Trim(aryAccs(1, intCounter))& &quot; '&quot;, , , 0

If .EOF Then
.AddNew
.Fields(&quot;WorkstationId&quot;) = Trim(aryAccs(0, intCounter))
.Fields(&quot;MDBFiles&quot;) = Trim(aryAccs(1, intCounter))
Else
.Fields(&quot;MDBFiles&quot;) = Trim(aryAccs(1, intCounter))
If Not .EOF Then
.MoveNext
End If
End If
.Update
End With
Next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top