I have a main form (F-BMSClasses) with a subform (F-BMSAttendance). The main form displays one of the possible classes students can be registered for, and the subform displays who is registered or allows more to be registered. In the subform Current Event, I placed this code to limit the number of records:
Private Sub Form-Current()
‘Code to limit the class size to 14.
Dim cnt As Long
cnt = Me!RecordsetClone.RecordCount
If cnt<>0 and cnt >13 Then
Me.AllowAdditions = False
Else
Me.AllowAdditions = True
End If
With this code, I seem to be able to add records to classes that have no one in them, and I can add students to those classes that have less than 14. If I reach capacity in any one class the code successfully triggers the AllowAdditions = False statement for that class. However, when I move to another class (the next record of the main form) from that point on the AllowAdditions = False statement seems to persist, despite the class being empty or under capacity. In previous postings I have read that the Me!RecordsetClone.movelast method may need to be applied. I have tried using it in various positions within the above code and have had no success. Can someone suggest a correction or a whole different direction to control the number of subform records? (I have toyed with a control on the main form [txtCountStaff] with its data source the dCount function. I was able to correctly display in that control the number of records in the subform. I even used it to hide or unhide the subform depending on the count, but does not prevent someone from overbooking the class once they are in the subform.) Please share your collective wisdom…Thanks!
Private Sub Form-Current()
‘Code to limit the class size to 14.
Dim cnt As Long
cnt = Me!RecordsetClone.RecordCount
If cnt<>0 and cnt >13 Then
Me.AllowAdditions = False
Else
Me.AllowAdditions = True
End If
With this code, I seem to be able to add records to classes that have no one in them, and I can add students to those classes that have less than 14. If I reach capacity in any one class the code successfully triggers the AllowAdditions = False statement for that class. However, when I move to another class (the next record of the main form) from that point on the AllowAdditions = False statement seems to persist, despite the class being empty or under capacity. In previous postings I have read that the Me!RecordsetClone.movelast method may need to be applied. I have tried using it in various positions within the above code and have had no success. Can someone suggest a correction or a whole different direction to control the number of subform records? (I have toyed with a control on the main form [txtCountStaff] with its data source the dCount function. I was able to correctly display in that control the number of records in the subform. I even used it to hide or unhide the subform depending on the count, but does not prevent someone from overbooking the class once they are in the subform.) Please share your collective wisdom…Thanks!