Restricting Number of Records

  • Thread starter Thread starter manish.amina
  • Start date Start date
M

manish.amina

I have a master-detail form, in which I want to restrict the number of
forms in the detail section to 6 or less. Any Ideas how to accomplish
this?

Regards
Manish
 
I have a master-detail form, in which I want to restrict the number of
forms in the detail section to 6 or less. Any Ideas how to accomplish
this?

Regards
Manish

You'll need some VBA code in the Subform's BeforeInsert event, like:

Private Sub Form_BeforeInsert(Cancel as Integer)
If DCount("*", "DetailTableName", "[ID] = " & Me!ID) >= 6 Then
Cancel = True
MsgBox "Sorry, only six items allowed", vbOKOnly
End If
End Sub

where ID is the linking field.

John W. Vinson[MVP]
 
Back
Top