I'd use a separate table because adding a field may produce results that you
don't want. For instance: The first record to open will have the latest
value. That record will change depending upon filters, queries, etc. Some
records will never have any data, yet there will always be a field. The code
I wrote is really for a field, and as a matter of fact, you can leave out
the Max() function with a separate table, because, as written, there will
never be more than 1 record you'll also need to write that record back to
the table, in the form's close event. Do that like (this is untested):
Function WriteCount() As Long
On Error GoTo Error_Handler
Dim db As DAO.Database
Dim rst As DAO.Recordset
Set db = CurrentDb
Set rst = db.OpenRecordset("Select * FROM tblHits")
With rst
.Edit
!MaxHits = Me.txtHitCount
.Update
End With
Exit_Here:
rst.Close
Set rst = Nothing
Set db = Nothing
Exit Function
Error_Handler:
MsgBox Err.Number & ": " & Err.Description
Resume Exit_Here
End Function
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com