mikeg8
I guess you know about the menu bar used as a default by Access ... "Record xx of yy"
This gives you the current record you are on plus the the total records. But RJFost has made a point that these numbers are relative. Depends on the query you running - straight from a table, or uses a join with other tables.
The record number is also relative -- depends on the sort - Sort by last name vs first name will give you totally different "current" record number.
Moving to the coding level, since you have already develed into it on some of your other posts...
This is for DAO. A slightly different syntax is required for ADO
dim dbs as DAO.database
dim rst as DAO.recordset
dim lngCount as Long
set dbs = currentdb()
set rst = dbs.openrecordset("YourTableOrQuery"
rst.MoveLast
lngCount = rst.RecordCount
rst.Close
dbs.Close
Likewise, you can programatically track the current record "number" in a loop...
Dim intCur as Long
rs.MoveFirst
intCur = 0
For / While loop
intCur = intCur + 1
rst.MoveNext
end of loop
Lastly, autonumbers...
For the primay key, many developers will use a autonumber during the table design. If using a database that is not replicated, Access will assign a serial number for the primary key -- 1, 2, 3, ...
So this serial number will give you
some idea of the "current record number". BUT, there are some things to consider with the use autonumbers.
- If the user aborts the entry of a record, the autonumber will have advanced any way. So the "pure" numeric sequence will have been broken.
- If records are deleted, the autonumber does not renumber the records.
Also, read MichaelRed' FAQ on autonumbers.
Richard