A
Arvin Meyer [MVP]
Here's a simpler piece of code which I've tested with both On Load and
OnOpen:
Function CountOpen()
On Error GoTo Error_Handler
Dim db As DAO.Database
Dim rst As DAO.Recordset
Set db = CurrentDb
Set rst = db.OpenRecordset("tblDBOpen", dbOpenDynaset)
With rst
rst.MoveFirst
rst.Edit
rst!CountDB = rst!CountDB + 1
rst.Update
End With
Exit_Here:
On Error Resume Next
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
OnOpen:
Function CountOpen()
On Error GoTo Error_Handler
Dim db As DAO.Database
Dim rst As DAO.Recordset
Set db = CurrentDb
Set rst = db.OpenRecordset("tblDBOpen", dbOpenDynaset)
With rst
rst.MoveFirst
rst.Edit
rst!CountDB = rst!CountDB + 1
rst.Update
End With
Exit_Here:
On Error Resume Next
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