Limiting number of records entered

  • Thread starter Thread starter Andy
  • Start date Start date
A

Andy

Hi;

Not sure whether this is a query or a form question.

My application has 4 sections. Each section has an "Other" sub-section.

3 of the sections can include upto 2 "Others" and the 4th upto 5 "Others".
AND NO MORE.

How do you limit the amount of entries in a form or the number of returns in
a query?

Thank you.

Andy
 
Andy said:
Hi;

Not sure whether this is a query or a form question.

My application has 4 sections. Each section has an "Other"
sub-section.

3 of the sections can include upto 2 "Others" and the 4th upto 5
"Others". AND NO MORE.

How do you limit the amount of entries in a form or the number of
returns in a query?

Thank you.

Andy

To limit the number of entries in a form, you could set the form's
AllowAdditions property in its Current event, based on the number of
records in its recordset. If this form is used as a subform, you'll
also need to do this procedure in the parent form's Current event, so
I'd recommend code like this:

'---- code for the "limited" form's module ----
Public Sub LimitRecords()

Const conRecLimit = 2

With Me.RecordsetClone
If .RecordCount > 0 Then .MoveLast
Me.AllowAdditions = (.RecordCount < conRecLimit)
End With

End Sub

Private Sub Form_Current()

LimitRecords

End Sub

'---- end code for the "limited" form's module ----

'---- code for the parent form's module ----
Private Sub Form_Current()

Call Me.SubformControlName.Form.LimitRecords

End Sub

'---- end code for the parent form's module ----

You would substitute the name of subform control (that is displaying the
"limited" form) for "SubformControlName" in the above.
 
Back
Top