Limiting continous forms

T

Tim Birky

I am trying to limit the number of entries on a form to 5
per person.

I am making a guest entry system and on the main form,
the person selects their name from a drop-down list and
then in a subform they enter in their guests names. The
problem I am having is that I want to limit the number of
guests to 5 and the for just continous on forever so they
can enter as many guests as they wish.

Please help! Thanks!
 
S

Steve Schapel

Tim,

There could be a number of approaches to this. A crude but effective
idea might be code like this on the form's AfterUpdate event...
Me.AllowAdditions = Me.RecordsetClone.RecordCount < 5

- Steve Schapel, Microsoft Access MVP
 
J

John Vinson

I am trying to limit the number of entries on a form to 5
per person.

I am making a guest entry system and on the main form,
the person selects their name from a drop-down list and
then in a subform they enter in their guests names. The
problem I am having is that I want to limit the number of
guests to 5 and the for just continous on forever so they
can enter as many guests as they wish.

Please help! Thanks!

I'd suggest code in the Form's BeforeInsert event:

Private Sub Form_BeforeInsert(Cancel as Integer)
If Me.RecordsetClone.RecordCount >= 5 Then
Cancel = True
MsgBox "Only five guests may be entered"
End If
End Sub
 
H

Howhiareu

On the Form_AfterUpdate event, you will have to evaluate the count of
guests and prevent additions after that condition is met. You should
be able to set the Form's AllowAdditions property to false once the
condition is met.


There are several ways to determine the recordcount, not knowing how
your system is set up makes it hard to determine which would be the
best for you.
 

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