Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question about ADO Recordcount

Status
Not open for further replies.

EdRev

Programmer
Aug 29, 2000
510
US
I saw this thread before but the search is down, so I can't look for it.

I created an ADO recordset with a few records on it. How do I get the total recordcount and the position of each record (i.e Record 2 of 25).

Also, I have a Next and Previous buttons to navigate through the recordset. Although I coded for EOF and BOF, when the beginning / end of file is reached, an empty record is displayed before the first / after the last record.
 
Hi,

Use can use .recordcount to get the total number of records (make sure that you got the right cursortype. Use adOpenStatic for if you're using recordcount and only going to read from the recordset).
Use .absoluteposition to set the posistion (agian make sure that you've got the right cursortype).

Here's some code from msdn to navigate a recordset.

------------------------------------------------------------
SUB First_OnClick
ADC.Recordset.MoveFirst
END SUB

SUB Next_OnClick
If ADC.Recordset.EOF Then 'cannot move beyond bottom record
ADC.Recordset.MoveFirst
Exit Sub
End If

ADC.Recordset.MoveNext
END SUB

SUB Prev_OnClick
If ADC.Recordset.BOF Then 'cannot move beyond top record
ADC.Recorset.MoveFirst 'Get out of BOF buffer
ADC.Recordset.MoveLast
Exit Sub
End If
ADC.Recordset.MovePrevious
END SUB

SUB Last_OnClick
ADC.Recordset.MoveLast
END SUB

-----------------------------------------------------------
Sunaj
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top