DCount function for a subform

Beany

Registered User.
Local time
Today, 07:20
Joined
Nov 12, 2006
Messages
155
Hi,

I cant seem to construct some code for my subform.

I want to basically count how many records there are in a subform....

Can someone please help? thanks
 
place a control in the form footer and use the following as the control source

=Count(*)
 
im confused...??!!

im using this for counting users from a table:

DCount("*", "<Asset>") --- this is in the control source of a textfield.


I need it to count the subform records??
 
Replace the * with the field name of the Unique Reference in the table and of course you don't need <> around the the table name. use [ ] instead.
 
ok thats fine,

DCount("User", "Asset") will search for records in a table...

I'd prefer the correct one for counting records for each user in a Subform?

thanks
 
Have you thought of using DLOOKUP but based on a query with Totals where the "User" field parameter is Group by and the Table URN is Count
 
I wouldnt know as i havent used DLOOKUP before..

if possible, Can you please show me an example of how a textfield counts records in a subform? (in the same form)...


thanks
 
ive attached my database,

on Form1, im trying to get text16 (textbox) to show the number of records in the subform.....

A user is selected from a combobox from the mainform "AssetMain" and details are shown in the Form1.

Can someone have a look?

thanks
 

Attachments

Beany:

No DCount is necessary. Just put a text box in the subform footer to set the count (I chose =Count([ID]), name the text box txtSubFormCount, and then put this reference in the control source of your text box on the main form:
=[Asset subform].Form!txtSubFormCount

See attached.
 

Attachments

Cheers Boblarson.. thank you..

What if there were no records, would it automatically return 0?
 
Ok Boblarson,

if you remember, just recently you modified my database and placed the subform in my main form.

for some reason i cant replicate the count function to this database.... (the count function you showed me in this thread)

im moved the displaying textbox to the main form...

ive checked all spelling and it seems to be ok..but i keep getting *Name? error message


can you please have a look..youve been great help..
thanks
 

Attachments

Ok Boblarson,

if you remember, just recently you modified my database and placed the subform in my main form.

for some reason i cant replicate the count function to this database.... (the count function you showed me in this thread)

im moved the displaying textbox to the main form...

ive checked all spelling and it seems to be ok..but i keep getting *Name? error message


can you please have a look..youve been great help..
thanks

Here you go.
 

Attachments

Thanks Boblarson, your amazing..

the second textbox i had was for the user name....

so ive changed it to =([User]), and it displays the user... i was just testing it, trying to self-teach :)
 

Users who are viewing this thread

Back
Top Bottom