View Single Post
  #4  
Old March 3rd, 2010, 02:18 AM posted to microsoft.public.access.forms
Tom van Stiphout[_2_]
external usenet poster
 
Posts: 1,653
Default Limit rows in subform based on field in main form

On Wed, 03 Mar 2010 02:09:55 GMT, "PieterLinden via AccessMonster.com"
u49887@uwe wrote:

Interesting. I took his question to mean: I may have more than N
records, and the user can only enter data in the first N ones.
You took it to mean: I want to prevent the user from entering more
than N rows.

-Tom.
Microsoft Access MVP


cynteeuh wrote:
I have a main form that has a number field (this field inidcates the number
of seats available). I want the subform to only allow the user to enter data
in rows that are equal or less than than the number field in the main form.

please help with code and best place to enter.

many thanks!!!


You need to use a RecordsetClone to get the count of records in the subform.
Then in the BeforeInsert event, check that

If RecordsetClone.RecordCountMAX_CHILD_RECORDS Then
'MsgBox...
Cancel = True
End If