Help with this SubForm Please

  • Thread starter Thread starter Shadow
  • Start date Start date
S

Shadow

How can I restrict the number of registering data in a subform?

I have a main form(frmCustomers). There's a subform(frmOrders) in this main
form that is used to input the orders. Both forms are linked with a ID field
base on a One-to-many relationship.
I have to restrict the user of this form to register only 7 orders in the
subform. If he wants to register more, he has to go to the next record on
the main from.

I appreciate any kind of help.

Ghalamkari
 
Cancel the Before Insert event of the subform.

The Event Procedure will look like this:

Private Sub Form_BeforeInsert(Cancel As Integer)
If Me.RecordsetClone.RecordCount >= 7 Then
Cancel = True
MsgBox "Start a new order."
End If
End Sub
 
I would suggest that :-

If Me.RecordsetClone.RecordCount < 7 Then
AllowAdditions = True
Else
AllowAdditions = False
End If

You may have to experiment with where you do this to ensure that Access has not
already moved to a new record that you are attempting to disallow. The Current
or BeforeUpdate events of the subform would seem likely possibilities.

Good Luck!
 
Back
Top