DCount

A

Alisa Bull

Has anyone used DCount successfully?

I have a form (Children2) that displays the names and birthdates of children
for a given customer. The Children2 form uses the following to get the
associated children:

(SELECT Children.* FROM Customers INNER JOIN Children ON
Customers.CustomerID = Children.CustomerID WHERE
(((Children.CustomerID)=[forms]![Orders by Customer]![CustomerID]));

On the main form I'm using a text box meant to display the number of
children (or children records) for a given customer. The control source for
the text box has the following:

=DCount("*","Children","CustomerID = " & [Me]![cboCustomerID])

The child records are stored in a table called Children.

Instead of counting the associated child records, I'm getting #Name?. Can
anyone shed any light on what's wrong? I'd be happy to supply more info if
need be. Thanks in advance for any help.
 
T

tina

try

=DCount("[CustomerID]","Children","[CustomerID] = " &
[Forms]![FormName]![cboCustomerID])

if CustomerID is a text value, not numeric, try

=DCount("[CustomerID]","Children","[CustomerID] = '" &
[Forms]![FormName]![cboCustomerID] & "'")

hth
 
K

Ken Snell

Or leave out the Forms reference because the control is already in the
current form:

=DCount("[CustomerID]","Children","[CustomerID] = " & [cboCustomerID])

You cannot use the Me reference in a control's control source expression. Me
is useful only within VBA code module.

--
Ken Snell
<MS ACCESS MVP>

tina said:
try

=DCount("[CustomerID]","Children","[CustomerID] = " &
[Forms]![FormName]![cboCustomerID])

if CustomerID is a text value, not numeric, try

=DCount("[CustomerID]","Children","[CustomerID] = '" &
[Forms]![FormName]![cboCustomerID] & "'")

hth

-----Original Message-----
Has anyone used DCount successfully?

I have a form (Children2) that displays the names and birthdates of children
for a given customer. The Children2 form uses the following to get the
associated children:

(SELECT Children.* FROM Customers INNER JOIN Children ON
Customers.CustomerID = Children.CustomerID WHERE
(((Children.CustomerID)=[forms]![Orders by Customer]! [CustomerID]));

On the main form I'm using a text box meant to display the number of
children (or children records) for a given customer. The control source for
the text box has the following:

=DCount("*","Children","CustomerID = " & [Me]! [cboCustomerID])

The child records are stored in a table called Children.

Instead of counting the associated child records, I'm getting #Name?. Can
anyone shed any light on what's wrong? I'd be happy to supply more info if
need be. Thanks in advance for any help.


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.551 / Virus Database: 343 - Release Date: 12/11/03


.
 

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