Public Sub SetFormAllowAdditions( _
ByVal frm As Form, _
ByVal lngRecordCountMax As Long)
' Limit count of records in (sub)form to that of lngRecordCountMax.
' 2004-10-06, Cactus Data ApS, CPH
'
' Call in (sub)form:
'
' Private Sub LimitRecords()
' Const lngRecordsMax As Long = 5
' Call SetFormAllowAdditions(Me.Form, lngRecordsMax)
' End Sub
'
' Private Sub Form_AfterDelConfirm(Status As Integer)
' Call LimitRecords
' End Sub
'
' Private Sub Form_AfterInsert()
' Call LimitRecords
' End Sub
'
' Private Sub Form_Open(Cancel As Integer)
' Call LimitRecords
' End Sub
Dim booAllowAdditions As Boolean
With frm
booAllowAdditions = (.RecordsetClone.RecordCount < lngRecordCountMax)
If booAllowAdditions <> .AllowAdditions Then
.AllowAdditions = booAllowAdditions
End If
End With
End Sub