DCount

  • Thread starter Thread starter Alisa Bull
  • Start date Start date
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.
 
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
 
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


.
 
Back
Top