Number of Records

  • Thread starter Secret Squirrel
  • Start date
S

Secret Squirrel

Is there a way to limit the number of records in a table? I need to have the
number of records limited to 50 in one of my tables.
 
J

John W. Vinson

Is there a way to limit the number of records in a table? I need to have the
number of records limited to 50 in one of my tables.

One way is to have a Primary Key integer field, with a validation rule
0 AND <= 50

This gives you only fifty possible records, since the primary key must be
unique (by definition) and the validation rule restricts the allowed values.

You'll need to manually reenter the PK value after a record has been deleted,
though - an autonumber won't work in this context.
 
T

Tom van Stiphout

On Sat, 8 Nov 2008 08:36:02 -0800, Secret Squirrel

There is nothing built-in to do that, so you'll have to write the code
yourself. If you have a form bound to a table, you could write in
Form_BeforeInsert:
if me.recordsetclone.recordcount > 50 then
Msgbox "Max recs reached"
Cancel=True
end if

-Tom.
Microsoft Access MVP
 

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