I am creating a form, the form contains a subform with 1 field and multiple text records. I want to insert a text box in my form that will count the number of text records in my subform... obviously the count() functions doesn't work because these are text fields... I thought DCount may work but i'm not quite sure how to use it any advice???
Counting Text fields in a form
Collapse
X
-
If you want this on the master form:
>Child form
Footer: Insert textbox
(You can set the footer visible property to No and/or close the footer size down to basically nothing if you are using one of the form views instead of datasheet view. Also you could place this in the header... shrug)
Name: rcdCount
Visible: false
Control Source:=count([fieldname])
(or=count(*))
>Parent form
Insert Text box
Format and name as desired
Control Source =[fsubformcontain ername]![rcdCount]
>> of course, if you want the display on the subform, then modify step one as needed and omit step two :-)Last edited by zmbd; Jan 31 '16, 09:55 PM. -
This doesn't work because my form uses a lookup up wizard to display the subform... therefore each record has a different number of records in the subform. If I count the records in the subform then it gives me a total of all records not the number that is displaying in my formComment
-
You're not making yourself very clear. What was suggested should work if the instructions are followed properly. What exactly are you doing that isn't working?Originally posted by HelpJessHelpJess:
If I count the records in the subform then it gives me a total of all records not the number that is displaying in my form
If you write full and complete responses we can help you more easily than if you respond too quickly and without including all the relevant information. This will surely save you time in the end.Comment
-
HelpJess:
Lookup wizards are not available for creating a subform.
There is a control wizard, and that will create the subform based on either an existing form, a table, or a query. If you have based the subform directly on either a table or query then this complicates things; however, if you have used another form, then what I have suggested will work.
++ There is a look-up field wizard, that creates either a lookupfield or a multivalue field in the table - this is not a subform and is what I am suspecting is the root of your quandary based on your two posts.
I am not so certain there is a way to obtain the count of related records in such a field... something we'll have to dig in to deeper...
>> However, as NeoPa has pointed out, you need to clarify what you have done here so that we have a better idea as to which direction to go.
BTW:
Lookup fields are really only valuable for SharePoint destined applications, in all other cases (IMNSHO) it should be avoided like the plague... The Evils of Lookup Fields in Tables
Lookup fields hide from the user what a properly normalized database should be doing...
Database Normalization and Table Structures
LUF/MVF are well intentioned; however, nightmarish to handle in queries and in VBA.... let alone in a calculated control.Last edited by zmbd; Feb 1 '16, 05:58 AM.Comment
Comment