help with this sub form please

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
 
P

PC Datasheet

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top