Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Counting records in Subform

Status
Not open for further replies.

laura525

Technical User
Nov 8, 2004
11
0
0
US
I have a main form which contains a subform for entering some information. I only want the user to be able to enter four records at time in this subform. Is there a way for me to limit how many records can be entered in the subform?
 
Sure!

On the BeforeInsert Event for the subform put a check that Cancels the Event if the number of records exceeds 4 (or any other number).

You'll have to write some code (or call a query) that counts the number of records in the underlying recordsource for the subform, but that's a piece of cake too. Probably the simplest way is to use a RecordsetClone for the subform and utilise its RecordCount property.

Hope that helps.
 
Actually, you could also play around with the forms AllowAdditions property. Perhaps set it to False on the BeforeInsert or AfterInsert Event for the subform if the number of records is 4, otherwise set it to True.
Hope that helps.
 
How are ya laura525 . . . . .

[blue]Be more specific[/blue] in your operations here. [purple]Just cutting data entry off at four records seems a bit academic . . . .[/purple]

Calvin.gif
See Ya! . . . . . .
 
I am sorry my question seemed "academic" I have not had much experience with Access or writing code.
 
laura525 . . . . .

Your experience level is not an issue. We can help you. We just need more detail on your operations here.

For instance:
[ol][li]What criteria (if any) determines turning full editing back on?[/li]
[li]What criteria determines the next group of four records?[/li]
[li]What is the purpose of groups of four or four only?[/li][/ol]
Chances are we can suggest better implementation of what your trying to accomplish. ;-)

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top