Hi,
You can use a static variable (or a module level variable) to track the number of opens...
CODE
Option Compare Database
Option Explicit
Private m_OpenedCount As Integer
Private Sub Form_Open(Cancel As Integer)
If m_OpenedCount = 2 Then
Cancel = True
Else
m_OpenedCount = m_OpenedCount + 1
End If
End Sub
This would be reset each time the app is closed and reopened. You'd have to store that in a table to track it across more than one session.
That said, this seems an odd requirement... usually if there's some requirement (e.g. - don't do this if some criteria is true), we'll handle it on an actual data/task calculation rather than counting the instances that a form is opened. The count of form instances is prone to... misperformance, I'll label it, for lack of a better term.
What is the reasoning for not allowing the form to open a second time (or not allowing it to update a second time, in which case you'd move that logic to the BeforeUpdate or BeforeInsert event instead of the Open event)
hth