Limit records in sub-form

wllsth

Registered User.
Local time
Today, 09:15
Joined
Sep 17, 2008
Messages
81
I have a Form which contains a sub-form. I wish to limit the number of records entered/viewed on the sub-form to say 10. This is because I have pre-printed stationery which will only allow a limited number of sub-form records.
Any ideas ???
 
It is possible to print a fixed number of lines per page and this woudl allow you to not have to limit the number of records entered.

See:
How to Print a Constant Number of Lines Per Group

I use this with preprinted form with great success.

If you don't want to use the above method then:

You do not need to limit the number of records viewed, only the number of records added.

Use the sub form's On Current event like this:

Code:
Private Sub Form_Current()
    
    ' if 10 is the max records to enter
    If Me.RecordsetClone.RecordCount < 10  Then 
       Me.AllowAdditions = True
    Else
       Me.AllowAdditions = False
    End If
End Sub

or a more condensed version

Code:
Private Sub Form_Current()
    
    ' if 10 is the max records to enter
    Me.AllowAdditions = Me.RecordsetClone.RecordCount < 10

End Sub


Note: Both methods work identical.
 
I have a Form which contains a sub-form. I wish to limit the number of records entered/viewed on the sub-form to say 10. This is because I have pre-printed stationery which will only allow a limited number of sub-form records.
Any ideas ???
 
the danger is of course that you never realise there WERE more than 10 records.
 

Users who are viewing this thread

Back
Top Bottom