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!

Refering to the last record in a table

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
How do I refer to the number of a last record in a table. ie. if the table has 150 records, how do i find the number of the last record ?

Thanks
 
Hi,
You can use DAO to get the number of records and the number of records will correpond to the last record in the table.

Private Sub GetRecordNumber_Click()
Dim db as DAO>Database
Dim rs as DAO.Recordset
Set db= CurrentDB
Set rs= db.OpenRecordset("YourTableName",dbOpenDynaset)
If rs.RecordCount > 0 then
rs.MoveLast
rs.MoveFirst
MsgBox "There are " & rs.RecordCount & " records."
Else
MsgBox "Table contains no records"
End IF

rs.CLose
db.Close
Set rs=Nothing
Set db=Nothing

End Sub Hope it helps. Let me know what happens.
With regards,
PGK
 
Thanks,

Will give it a try later today and let you know.

Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top