Counting records in a subform

B

BT

I would like to count the number of records in a subform and if this number
is above a given amount, I want to set the AdditionsAllowed property of the
subform to false.

I am using DCount funtion and get some of the results I want. The problem is
I need it to set the property before any updates or changes take place. Can
you tell me which which event to use? Or should I be trying another approach?

thanks
Brian
 
M

Marshall Barton

BT said:
I would like to count the number of records in a subform and if this number
is above a given amount, I want to set the AdditionsAllowed property of the
subform to false.

I am using DCount funtion and get some of the results I want. The problem is
I need it to set the property before any updates or changes take place. Can
you tell me which which event to use? Or should I be trying another approach?


Use VBA code in an appropriate main form event procedure:

With Me.subformcontrol.Form.RecordsetClone
.MoveLast
If .RecordCount > N Then
Me.subformcontrol.Form.AllowAdditions = False
End If
End With
 
B

BT

Marshall Barton said:
Use VBA code in an appropriate main form event procedure:

With Me.subformcontrol.Form.RecordsetClone
.MoveLast
If .RecordCount > N Then
Me.subformcontrol.Form.AllowAdditions = False
End If
End With
 
B

BT

Thank you for the information. It is working fine, except I get an error ir
it is already on the last record.

is there a method to test if it is on the last record?

thanks again
BT
 
Top