On the subform's BeforeInsert event check if the number of saved records is equal to the main form control that contains the number. If it is equal to the number, cancel the record addition. If not, allow it. What you haven't said is where the count of the subform records has to come from. Could be a temporary table, a target table, or simply a Count() of the primary key field in the subform (so as to prevent counting blank fields in subform records). If you can figure out what to use the Count or DCount functions on, you should be able to adapt the following (which should count a PK field).
Code:
Private Sub Form_BeforeInsert(Cancel As Integer)
If Count([NameOfSomeField]) > Me.textboxWithNumber Then
MsgBox "Message Here", vbOKOnly
Cancel = True
End If
End Sub
The more we hear silence, the more we begin to think about our value in this universe.
Paraphrase of Professor Brian Cox.