PDA

View Full Version : Accessing the ith Record



BarkersIT
03-21-2007, 03:09 AM
Hello,

I have opened a database and created a recordset. I now want to loop through the recordset and access the last record. How can I access the ith record? I tried using MoveLast but it pointed to a record in the middle of the table and not the last record.


Dim db As Database
Dim rs As Recordset
Dim count As Integer
Dim rec As String
Dim inc As Integer

'open database
Set db = CurrentDb()
Set rs = db.OpenRecordset("Base Units")
count = rs.RecordCount
Debug.Print "Count = " & count
For inc = 0 To count
Debug.Print "inc = " & inc & " Count = " & count
If inc = count Then
Debug.Print "inc = Count"
'I want to access the ith record here
End If
Next inc
MsgBox "Current Record: " & rec
rs.Close

OBP
03-21-2007, 10:29 AM
All sorted now?

BarkersIT
03-22-2007, 01:48 AM
Yeah, cheers. It does exactly what i neeed. Cheers for the help.