Free NT Web Hosting, Free ASP Hosting, Free Web hosting, Free Hosting - DomainDLX
    

    Home
    Registration
    FAQs
    Terms of service
    Contact us

    Learn ASP
    Databases
    Articles

Moving through the records in a recordset is easy.  The recordset has only one open record at a time, the current record.  When moving through a record set you need to keep an eye on (by using code, not literally) the BOF and EOF properties of the recordset to make sure you don't go past the beginning or end of the set.  BOF stands for Beginning of File and EOF stands for End of File.  They will be True if you are at those points, False otherwise.

To change the current record, you can use these commands.

ADODB.RecordSet.MoveFirst
ADODB.RecordSet.MoveLast
ADODB.RecordSet.MoveNext
ADODB.RecordSet.MovePrevious

These should explain themselves very well.

When using the MovePrevious, you will be going backwards in the set, so be sure you don't go past the beginning of the set.  Watch the BOF property.  When using MoveNext, don't go past the end, and watch the EOF.

Here is an example of a loop that moves forward in a record set:

RS.MoveFirst
Do Until RS.EOF         'Check the EOF here on the Do part because if the MoveNext moves past the last record this will catch it before it runs the loop again.  If you put it on the loop part it will run risk of the running the loop again and causing an error.
RS.MoveNext

Loop

By: Matthew Holder