RecordSet.Edit Will only Update the Table on the Second Attempt

Hi Everyone,

So here is the code that i am using to update values in a table. I am using Postgre as the database (and i looked up the RecordSet rule and the rules state that the only RecordSet method that works for Postgre is the MoveNext method (RecordSet Rules)). Anyways the code below does in fact work, but only if i run it 2 times, it does not work on the first try. any ideas why this is (or ways around it)?

[code] lngAdjId = lngAdjustId
lngDlrAdjCode =ctlList.Cell(x,0).Val
strMasDlr = ctlList.Cell(x,1)
dblAmt = ctlList.Cell(x,3).Val
dblTaxRt = ctlList.Cell(x,4).Val

Dim Rst As RecordSet = mDBS.SQLSelect("SELECT * FROM TableName WHERE PrimaryKey="+_
CStr(lngDlrAdjCode) + ";")
If Rst<>Nil Then
  If Rst.RecordCount>1 Then
    strMsg= "Error Updating Dealer Rate..." + EndOfLine+EndOfLine + "Multiple Entries Found For Dealer Rate # " +_
    CStr(lngDlrAdjCode) + "!"
    GoTo ErrorIT
  Else
    Rst.Edit
    Rst.Field("daamteach").DoubleValue=dblAmt
    Rst.Field("dataxrate").DoubleValue = dblTaxRt
    Rst.Update
    If mDBS.Error= True Then
      strMsg= "Error Updating Dealer Rate..." + EndOfLine + EndOfLine + mDBS.ErrorMessage
      GoTo ErrorIT
    End If
  End If
End If[/code]

Thanks!

posting the same question twice, won’t provide any more or better answers

use an UPDATE…SET sql command instead of the SELECT and then recordset.edit method.
it will be easier, faster if you have a lot of (remote) records, and works all the time even if the recordset does not contain the primary key.