Group: microsoft.public.access
From: "rquintal@sympatico.ca"
Date: Friday, October 19, 2007 5:27 PM
Subject: Re: How to automate copying data from previous record to the current

On Oct 19, 5:16 pm, Qawi wrote:
> All, I have a table that has missing values for fields. I would like to know
> how to copy the contents of fields from a previous record to the current one.
> I attempted to do it in an update query but was unsuccessful. Also tried to
> create a macro that invoke <'> but that didn't work either. Any
> suggestions would be appreciated. The table has thousands of records so
> manually copying the fields would be prohibitive.


you could use a recordset,
storing each field to a variable if the field is not null, and writing
from the variable if the field is null
The code below is untested, and needs to be adjusted to your table


dim rs as dao.recordset
set rs= currentdb.openrecordset("SELECT * from table order by ?????")
dim FldCount as integer
dim FldPointer as integer
FldCount = rs.fields.count
dim fieldvalues(FldCount)
do while not rs.eof
For fldPointer = 0 to FldCount - 1
if isnull(rs!fields(fldpointer)
fieldvalues(fldPointer) = rs!fields(fldpointer)
else
rs!fields(fldpointer) = fieldvalues(fldPointer)
end if
next fldpointer
loop


Safety Articles | News in English | 20lbs in 30 days | Bluegrass | Usenet Newsfeeds