Counting records in a subform

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top