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



Tony Girgenti wrote:
Hello Graham.

I'd like to try to explain what i want to do using the data at the end of this post.

The data is in a csv file and imported into a recordset. I don't have any need to update the data source or sort any data. It is simply read into the recordset. There is no query in the sense that i'm extracting a set of records from the source. I'm using all the records in the ascii, text, csv file.

If you look at the data , you can see that the first row has "00050-00-0" as the first field. The fourth row has "00050-00-0" as the first field. This constitutes a group of rows in the recordset, four rows.

What i want to do to the recordset is take the "000048815.40" from row four and put it into the first row after the first comma after the "37.00". So, after that copy/move, the first row would look like this:

"00050-00-0",,"27202475",037.00,000048815.40,,,Y,Y,N,Y,N

There are other fields i want to move/copy also, but that's not important here, since the idea here is to get the logic down.

Once the move/copy is done, i want to delete the fourth row then go onto to the row that has "00050-81-7" and do the same thing. As you can see, that group consists of only two rows.

I hope this helps you understand what i want to accomplish with the recordset.

I'm sorry, but the comments you are making just don't seem to apply to what i need. I hope this does not offend you in any way. I'm just having a hard time trying to figure out how your comments apply to my problem.

Thanks for all of your help so far.
Tony

"00050-00-0",,"27202475",037.00,,,,Y,Y,N,Y,N
,,"27202490",037.00,,,,Y,Y,N,Y,N
,,"27206490",035.00,,,,Y,Y,N,Y,N
"00050-00-0","FORMALDEHYDE",,,000048815.40 ,000002599 ,00027,,,,,
"00050-81-7",,"12550055",100.00,,,,N,Y,N,N,N
"00050-81-7","L-ASCORBIC ACID",,,000000275.65 ,000000016 ,00027,,,,,
"00056-81-5",,"29950551",100.00,,,,N,Y,N,N,N
,,"56567421",100.00,,,,N,Y,N,N,N
"00056-81-5","GLYCERIN",,,000007163.00 ,000000256 ,00027,,,,,

<snip>

Before my wife drags me off, my suggestion is to pull the data in one line at a time from the file, push it into a dynamic array of UDTs until your "total" line arrives, extract the data from that UDT and shove it into the spot you want it, in the first UDT.
Save the current data (four lines in your example, less the last UDT array)
redim the UDT array, and start on the next group.
I think I see what you're doing - moving the "000048815.40" ( and probably the "FORMALDEHYDE" as well) into their respective slots in the first line.

UH. OH.. My wife is here, giving me the evil eye!!!

Bye!!!


Graham



.



Relevant Pages

  • Re: Update fields in previous row from fields in current row
    ... I don't think i can "pull the data in one line at a time". ... The data is in a csv file and imported into a recordset. ... in the first UDT. ...
    (microsoft.public.vb.database.ado)
  • Re: implement Save button
    ... If you are using Connection.Execute "Update/Insert Into..." ... update the database. ... Your solution is fine and in this way you do not need to a recordset. ... You will use a UDT to recording the status of of controls on current form. ...
    (microsoft.public.vb.enterprise)
  • Re: how to export the result
    ... I have created my UDT and I have my recordset - how do I do the next part? ... >> I have a sp in SQL and I want to export the results to a Fixed Width ... > disk, move to the next record, and repeat. ...
    (microsoft.public.vb.syntax)
  • Re: how to export the result
    ... > In Access I would simply right a little code to export the query using a ... recordset, put the data from the current row into the UDT, write the UDT to ... disk, move to the next record, and repeat. ...
    (microsoft.public.vb.syntax)
  • Re: Excel Export with vbscript
    ... an empty excel worksheet opens. ... I am trying to to export a recordset to excel using> asp/vbscript. ... > dim bcolor ... > ' So Field 0 would be the first field in the SQL statement. ...
    (microsoft.public.scripting.vbscript)