Re: Update fields in previous row from fields in current row
- From: Tony Girgenti <tony(nospam)@lakesideos.com>
- Date: Tue, 29 Jan 2008 10:37:01 -0800
Hello Ralph.
Maybe if i explain what i'm trying to do with the data, you can tell me what
to do.
The rows in the recordset contain lines of inventory items. Each group of
items has a totals line at the end of the group in a separate row. There can
be many groups and a group can have as few as one item, so each group will
have at least two rows.
I want to find the total line for each group, take the totals fields for
each group and put those totals on the first row of the group, delete the
totals line.
Each row in the recordset has all the fields that are in both the items rows
and the totals rows, so i don't have to create new fields in the target row.
Thanks for all of your help.
Tony
"Ralph" wrote:
.
"Tony Girgenti" <tony(nospam)@lakesideos.com> wrote in message
news:uUAKLAoYIHA.4696@xxxxxxxxxxxxxxxxxxxxxxx
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
First off, the last two lines in your code ...
casInputFileRecordset.MoveNextCaptures the bookmark for the 'next' record. Not the one you are chewing on.
rsMark = casInputFileRecordset.Bookmark
I really don't know if you mean to use the "last" row or some previous row
of interest. (Which is important because one can never assume the exact
order of records in a recordset unless you specifically request one.) That
is the only reason I suggested that you take a look at "Bookmarks". It was
probably an unnecessary distraction.
In the example above you could do this ...
[Warning! Air Code follows]
Dim vLastValue As Variant 'only because I don't know its type
casInputFileRecordset.Open
casInputFileRecordset.MoveFirst
' have to have some kind of default value for the first one
' vLastValue = <default>
Do Until casInputFileRecordset.EOF
If casInputFileRecordset.Fields("CASNumber").Value <> "" Then
casInputFileRecordset.AddNew
casInputFileRecordset.Fields("CASNumber").Value = vLastValue
casInputFileRecordset.Update
Else
vLastValue = casInputFileRecordset.Fields("CASNumber").Value
End If
casInputFileRecordset.MoveNext
Loop
- Follow-Ups:
- References:
- Update fields in previous row from fields in current row
- From: Tony Girgenti
- Re: Update fields in previous row from fields in current row
- From: Ralph
- Re: Update fields in previous row from fields in current row
- From: Tony Girgenti
- Re: Update fields in previous row from fields in current row
- From: Ralph
- Update fields in previous row from fields in current row
- Prev by Date: Re: Connection to SQL Server on Vista
- Next by Date: Re: Connection to SQL Server on Vista
- Previous by thread: Re: Update fields in previous row from fields in current row
- Next by thread: Re: Update fields in previous row from fields in current row
- Index(es):
Relevant Pages
|
Loading