Guys,
One problem inherent in any "find gaps" algorithm is that it is often not run (cannot be run) at exactly the time that the record is inserted (certainly not if it is also visible to the operator first). Even if it finds the recordset perfectly, it may still cause problems.
The approach that OB was trying to follow is actually perfect here. He was trying to determine from the OP (MyWaterloo) exactly why he was after what he was requesting. That is the crux of the matter (See post #7).
MyWaterloo should appreciate that he was asking the wrong question with his stated requirement. The key field is not a field by which you should try to determine the number of records in the table. The Count() (or DCount()) functions should be used for that. An AutoNumber field was never designed for that purpose, and shouldn't be used in such a way (unless problems are what you're after).
The code and SQL solutions are both interesting, but are probably not good fits for this question.
PS. As Fish's SQL (post #10) is quite informative anyway (there could be a number of occasions where techniques like this can be used) I've just laid it out a little more clearly. Have another look and see if it makes sense now.
One problem inherent in any "find gaps" algorithm is that it is often not run (cannot be run) at exactly the time that the record is inserted (certainly not if it is also visible to the operator first). Even if it finds the recordset perfectly, it may still cause problems.
The approach that OB was trying to follow is actually perfect here. He was trying to determine from the OP (MyWaterloo) exactly why he was after what he was requesting. That is the crux of the matter (See post #7).
MyWaterloo should appreciate that he was asking the wrong question with his stated requirement. The key field is not a field by which you should try to determine the number of records in the table. The Count() (or DCount()) functions should be used for that. An AutoNumber field was never designed for that purpose, and shouldn't be used in such a way (unless problems are what you're after).
The code and SQL solutions are both interesting, but are probably not good fits for this question.
PS. As Fish's SQL (post #10) is quite informative anyway (there could be a number of occasions where techniques like this can be used) I've just laid it out a little more clearly. Have another look and see if it makes sense now.
Comment