Record Sets

s.booth

Registered User.
Local time
Today, 18:41
Joined
Feb 5, 2002
Messages
23
I have a form that has two subforms linked together that are in datasheet view, when the first sub form is selected it shows the records related to it in the second subform.

Is there a way of counting the records in the second subform and showing them as a numeric value on the main form, i've tried Dcount on the underlying querry with no success.
 
Looking at the syntax for Dcount («expr», «domain», «criteria») I take it the <<expr>> would be the control on the suborm but what would the domain be ? bearing in mind I only want to count the records associated with the record selected on the first form and what do I do about the critera?
 
Look up Dcount in Access help. Expr is (generally) a control name or field name, domain is (generally) a table or form name. criteria are done in the third variable, just as if you were leaving the word WHERE off of an SQL expression. Keep in mind that the syntax will differ a bit for counting text fields vs. numeric fields (or date, or...)

HTH,
David R
 
I've now got DCount working but it counts all the records in the underlying querry. How do I count just the records that are showing in my linked subform. Can I refer to a control on the form using the underlying querry as the domain?
 
For text fields:
DCount("[TextField]", "tableName", "[TextField]= '" & Me![TextFieldControlOnForm] & "'")
For number fields:
If DCount("[NumField]", "tableName", "[NumField]= " & Me![NumFieldControlOnForm])

David R
 

Users who are viewing this thread

Back
Top Bottom