limit amount of records

T

tk

is ther a way to limit the number of records that can be inputted in to
the table?
so that after say 20 records the user can not enter any more, and also
a message pops up to tell them that they can not insert any more data
 
R

Rick Brandt

tk said:
is ther a way to limit the number of records that can be inputted in
to the table?
so that after say 20 records the user can not enter any more, and also
a message pops up to tell them that they can not insert any more data

If your table includes a uniquely indexed field that is an incrementing integer
and which has a validation rule of...

Between 1 and 20

Then the table cannot contain more than 20 records. You can put whatever text
you like in the ValidationText property.
 
A

Allen Browne

Use the BeforeInsert event procedure of the form where entries are made. Use
DCount() to get the number of records, and cancel the event if the maximum
has been reached.

Example:
Private Sub Form_BeforeInsert(Cancel As Integer)
If DCount("*", "Table1") > 20 Then
Cancel = True
MsgBox "No more!"
End If
End Sub
 
J

Joseph Meehan

tk said:
is ther a way to limit the number of records that can be inputted in
to the table?
so that after say 20 records the user can not enter any more, and also
a message pops up to tell them that they can not insert any more data

I can think of a number of issues depending on exactly what you want.
It is a per user limit? Is it a per session limit? Is is a per table
limit? What happens if they delete a record?
 

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