help with this sub form 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
 
Put the following code in the subform's OnCurrent event:

Dim Rst As DAO.Recordset
Set Rst = Me.RecordsetClone
If Rst.RecordCount <>0 Then
Rst.MoveLast
If Rst.RecordCount = 7 Then
MsgBox "You Have Reached The limit Of 7 Records In the subform"
Me.Parent.SetFocus
DoCmd.GoToRecord
End If
End If
 
Back
Top