View Full Version : Limiting Entries to equal a field value


AndrewS
09-21-2000, 11:47 PM
I have a form to record serial numbers against a job number. The job number has a field that indicates that x serial numbers should be logged against this job.
I would like to limit the entries of the serial numbers (sub form)to this set value and to ensure that, that many serial numbers are in fact recorded.
I have tried using a query to get the number of records that have already been entered, but the query does not update after every entry.

Travis
09-22-2000, 07:11 AM
Try using this:

In your subForm this event:

Private Sub Form_BeforeInsert(Cancel as Integer)
if me.recordsetclone.RecordCount> [Your TotalNumber of Allowed Serial#]
Cancel = True
Me.Undo
end If
end Sub

This will evaluate before they are allowed to continue if they can add a new record or not. By using the Recordsetclone there is no need to worry about looking at a query to find out how many records there are.

HTH

AndrewS
09-25-2000, 10:02 PM
Thanks For your reply , I'll give it a try and let you know.
Andrew