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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Limiting the number of records to be entered

Status
Not open for further replies.

12mase

Programmer
Apr 14, 2002
2
GB
HEY guys!
does ne1 know how to limit the number of records being entered into a subform? for example i wanna be able to enter 10 records but not over 10 !!!! HELP! PLEASE!!

Cheers

thanks very much!

Dan!
 
Dan,

Try adding the following code to the Before Insert event of your subform:

Private Sub Form_BeforeInsert(Cancel As Integer)
MaxRecords = 10
Dim F As Form: Set F = Me
If F.RecordsetClone.RecordCount > MaxRecords Then
MsgBox "Maximum number of records in subform(" & MaxRecords & ") exceeded. " & _
"Further additions not allowed. "
DoCmd.CancelEvent
End If

End Sub


Cheers,
Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top