Re: Update fields in previous row from fields in current row



Hello Ralph.

After reading up on Bookmarks, i'm still not sure of how to code this
problem. If i do it this way, i get an object required error on the
statement after the If. I can't figure out how to refer to the bookmark's
fields.

Dim rsMark As Variant
casInputFileRecordset.Open
casInputFileRecordset.MoveFirst
rsMark = casInputFileRecordset.Bookmark

Do Until casInputFileRecordset.EOF
If casInputFileRecordset.Fields("CASNumber").Value <> "" Then
rsMark.Fields("CASNumber").Value =
casInputFileRecordset.Fields("CASNumber").Value
End If
casInputFileRecordset.MoveNext
rsMark = casInputFileRecordset.Bookmark
Loop

Thanks,
Tony

"Ralph" <nt_consulting64@xxxxxxxxx> wrote in message
news:OFpDKinYIHA.6140@xxxxxxxxxxxxxxxxxxxxxxx

"Tony Girgenti" <tony(nospam)@lakesideos.com> wrote in message
news:O1msnRjYIHA.4808@xxxxxxxxxxxxxxxxxxxxxxx
Hello.

Developing a VB6, SP6 program using ADO.

If i cycle through a recordset and want to update a previous row with
fields
from the current row, how would i do that? I have the basic logic as you
can see below, i just don't know how to refer to a recordset row that has
already been read.

casInputFileRecordset.Open
casInputFileRecordset.MoveFirst
Do Until casInputFileRecordset.EOF
If casInputFileRecordset.Fields("CASNumber").Value <> "" Then
(previous row) casInputFileRecordset.Fields("CASNumber").Value =
(current row) casInputFileRecordset.Fields("CASNumber").Value

End If
casInputFileRecordset.MoveNext
Loop

Any help would be gratefully appreciated.

Thanks,
Tony


Simply capture the "last" values as you are stepping through the
Recordset.

You might also take a look at "Bookmarks".
http://www.w3schools.com/ado/prop_rs_bookmark.asp
[You have to use either the "adOpenKeyset" or "adOpenStatic" cursor type.]

Capture the Bookmark of the row of interest, then use it to refer to that
record again.

-ralph





.



Relevant Pages

  • Re: Zeilen im Datagrid bewegen
    ... Was kannst Du wie beim DG zur Entwurfszeit mit dem ADODC bearbeiten? ... > datagrid.rebind die bookmarks wieder löscht. ... Datensatz machen. ... solange das Recordset nicht neu geladen wird. ...
    (microsoft.public.de.vb)
  • Re: Bookmark 3159 nach Update
    ... Es machen wohl die von Access automatisch ... eingestellten Bookmarks Probleme. ... Es geht um ein Treeview, das mit Daten aus Recordset rs_show beliefert ...
    (microsoft.public.de.access)
  • one column listbox, multiple bookmarks, spreadsheet link
    ... spreadsheet using the MVP method from "Load a ListBox from a Named ... different bookmarks on the document should be filled out. ... ' Set the number of Columns = number of Fields in recordset ...
    (microsoft.public.word.vba.userforms)
  • Re: MORE sql Query
    ... A single connection can be re-used ... The first field in the recordset has an ordinal position of zero, ... So you can use rsto refer to it. ... This email account is my spam trap so I ...
    (microsoft.public.inetserver.asp.general)
  • Re: ADODB.Recordset.Bookmark
    ... Thanks for the info. I'm not really a beginner developer, just new to ADO ... I changed the cursor type to static, and bookmarks work, but now I can't ... property of the connection or recordset that can tell me whether the ...
    (microsoft.public.vb.database.ado)

Loading