How to limit subform to one record?

  • Thread starter Thread starter markmarko
  • Start date Start date
M

markmarko

I have certain instances where I need a subform to be able to accept one
record, and no more.

I've been trying setting allowadditions to false if dcount (records for that
mainform record) >0, but I can't get the setup right in terms of which event
to trigger it, etc.

Any advice?
 
I have certain instances where I need a subform to be able to accept one
record, and no more.

I've been trying setting allowadditions to false if dcount (records for that
mainform record) >0, but I can't get the setup right in terms of which event
to trigger it, etc.

Any advice?

I'd use the Form's (subform's) BeforeInsert event:

Private Sub Form_BeforeInsert(Cancel as Integer)
If Me.Recordcount > 1 Then
MsgBox "Only one record allowed", vbOKOnly
Cancel = True
End If
End Sub

John W. Vinson [MVP]
 
Back
Top