Can i set the maximum number of records in a table

S

Sparky

Is it possible to set a maximum nummber of records that can be filled in.
I only want to allow 20 records, this being the maximum nuber i want to sign
on to a college course.
 
N

Nikos Yannacopoulos

Sparky,

Assumping you have a courses form and sign on students through a subform
in the courses form, then all you need is this piece of code in the
subform's Current event:

If Me.NewRecord Then
If Me.RecordsetClone.RecordCount = 20 Then
MsgBox "Sorry, class fully booked.", _
vbExclamation, "Sign-on rejected"
Me.Dirty = False
DoCmd.GoToRecord , , acPrevious
End If
End If

HTH,
Nikos
 
S

Sparky

Firstly thanks

I have only just started this table and do not have any subforms.
Also i am fairly new to Access and databases.
 
N

Nikos Yannacopoulos

To begin with, this is not something you can do in the table itself, if
this is what you had in mind. Moreover, all data entry should be made
through forms anyway, not directly in tables. With this in mind, the
restriction will be implemented somewhere in a data entry form. I
assumed a form/subform scheme that makes sense and was likely to be what
you have, but when you get to putting your user interface together, if
you end up with something different, hthe proposed code will have to be
modified accordingly. I can't be any more specific at this point, not
knowing what your forms will be.

Nikos
 

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