R
Robert Schripsema
We have a table with a "SortPos" function that is used by an
application to display records in a particular order on a form.
Normally, you'll have a clean, sequential list of numbers (1,2,3,4,5,
etc) in the various records in this table. Occasionally, a gap will
show up -- usually because a record was deleted, or a new record was
added to the end with an out of sequence record number (e.g., 99, when
there are only 50 records). Or, a SortPos value will be duplicated,
such that we'll have a sequence like 1,2,3,4,4,5,6,6,6,7,9, etc.)
I want to write an update query or process within Access that will
allow me to re-set those SortPos values to a new, clean set of
sequential numbers. I'm envisioning an update query that will retrieve
all the records in the table sorted by the CURRENT SortPos value, then
update the value of the SortPos field to the records position as
returned in the recordset. Something like this:
Update MyTable set SortPos = #RecordPos order by SortPos << clearly
this won't work,
To make something like this work, I need two things (at least):
1) A way to update the records in a particular order -- setting a sort
order on the Update statement
2) A way to access the current records position in the recordset that
is returned from #1.
Any of you geniuses out there have an idea?
Rob Schripsema
application to display records in a particular order on a form.
Normally, you'll have a clean, sequential list of numbers (1,2,3,4,5,
etc) in the various records in this table. Occasionally, a gap will
show up -- usually because a record was deleted, or a new record was
added to the end with an out of sequence record number (e.g., 99, when
there are only 50 records). Or, a SortPos value will be duplicated,
such that we'll have a sequence like 1,2,3,4,4,5,6,6,6,7,9, etc.)
I want to write an update query or process within Access that will
allow me to re-set those SortPos values to a new, clean set of
sequential numbers. I'm envisioning an update query that will retrieve
all the records in the table sorted by the CURRENT SortPos value, then
update the value of the SortPos field to the records position as
returned in the recordset. Something like this:
Update MyTable set SortPos = #RecordPos order by SortPos << clearly
this won't work,
To make something like this work, I need two things (at least):
1) A way to update the records in a particular order -- setting a sort
order on the Update statement
2) A way to access the current records position in the recordset that
is returned from #1.
Any of you geniuses out there have an idea?
Rob Schripsema