Count or DCount function

S

shiro

Hi all,
I have an unbound textbox on my main form.
I want to count related record in my subform.
Which one to be used,Count or Dcount?
And how to build it up,cause from my last attempt,
it return me #Error.
Please help.

Thank's
 
R

Roger Carlson

I'd create a textbox in the form footer of the subform what does the count.
It's control source would be something like this:
=Count([SomeFieldName]).

Assuming you named the textbox txtSubCount, you can reference this field on
the main form in an unbound text box like so:
=[Forms]![Form1]![subControl1].Form![txtSubCount]

The above assumes your mainform is called "Form1" and your subform CONTROL
is named "subControl1". Modify it to match your form/control names.

On my website (www.rogersaccesslibrary.com), is a small Access database
sample called "SubformReference.mdb" which illustrates this and other ways
to reference controls on subforms and subsubforms..

--
--Roger Carlson
MS Access MVP
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
 
S

shiro

I did to put count function in my subform footer like you explained.
But it still return me #Error,why?.Other function like Max,Min,Avg
works well in my subform footer.Strange isn't it?


Roger Carlson said:
I'd create a textbox in the form footer of the subform what does the count.
It's control source would be something like this:
=Count([SomeFieldName]).

Assuming you named the textbox txtSubCount, you can reference this field on
the main form in an unbound text box like so:
=[Forms]![Form1]![subControl1].Form![txtSubCount]

The above assumes your mainform is called "Form1" and your subform CONTROL
is named "subControl1". Modify it to match your form/control names.

On my website (www.rogersaccesslibrary.com), is a small Access database
sample called "SubformReference.mdb" which illustrates this and other ways
to reference controls on subforms and subsubforms..

--
--Roger Carlson
MS Access MVP
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L



shiro said:
Hi all,
I have an unbound textbox on my main form.
I want to count related record in my subform.
Which one to be used,Count or Dcount?
And how to build it up,cause from my last attempt,
it return me #Error.
Please help.

Thank's
 

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


Top