Is It Possible To Resequence A DAO Recordset From Within A Loop?

M_S_Jones

Registered User.
Local time
Today, 15:08
Joined
Jan 4, 2008
Messages
119
Hi,

Is it possible to move a record in a DAO recordset? I have some code that is looping through a recordset and allocating resource time to requirement. A late specification change has arisen and now on rare occasions there will be requirements that cannot be completed on the same day. I'm looking for a quick way to amend my code to deal with this. I've added a simple if statement to isolate the rare records in question, and check that they can be processed on the date about to be allocated to them. If they cannot, then I want to effectively swap the position of the current record with the next record, so that the next record can be allocated the time, and the former current record will be the first to be considered for the next available resource time. I've tried using the AbsolutePosition property, but don't seem to be able to set that. Any suggestions would be gratefully received.

Thanks,

Matthew
 
This is a tricky one. I'm 99% sure you can't move records around in a recordset.

Do you mean that, the first time a record is skipped in an iteration it needs to be the first record tested each and every following iteration until it is allocated?

If so, then I think you'd have to do something along the lines of:

Have a one-dimensional boolean array with as many elements as there are records that would flag whether each record has been allocated.

Each iteration would be a pass through that array looking for the first that hasn't and then going to that record in the recordset and checking it (having another array containing the primary keys of the records might be helpful there). If it passes the test - allocate it and change its element in the boolean array and then look from the start of the array for the first that needs allocating. If it doesn't move onto the next unallocated in the boolean array.

Although I dare there'd be a lot of alternative approaches but I doubt there's going to be a silver bullet for this.
 
Excellent, thanks for the suggestion. That will do what I'm hoping to achieve.

Thanks,

Matthew
 

Users who are viewing this thread

Back
Top Bottom