DCount error message

H

Hammond-Wandsworth

I'm replicating a DCount sum (that I have used before and which works) in a
new report control source with a different field from the same table - it is
now returning #Error in the field box when I run the report. The sum is
exactly the same except the field name and record have changed. Here is the
new (unworking) syntax:

=DCount("[SNT Ward / Borough]","[Master Table]","[SNT Ward /
Borough]=Bedford")

SNT Ward/ Borough being the field name; Master Table being the table name
and Bedford being the record name. The following is the old code for a
different report that works:

=DCount("[ASBO Began]","[Master Table]","[ASBO Began]=TRUE")

Is anyone able to tell me why this sum isn't working for my new report?
Please help. Thanks.
 
J

John Spencer

Try

=DCount("[SNT Ward / Borough]","[Master Table]", "[SNT Ward /
Borough]=""Bedford""")

You need to delimit the string with quote marks. In order to do so, you
need to use a pair of quote marks to end up with one quote mark.

You could also use the apostrophe ' instead of the two quote marks. I
prefer the pair of quote marks since if the name of the Borough contains an
apostrophe it handles that value correctly while the apostrophe solution
would cause an error.

=DCount("[SNT Ward / Borough]","[Master Table]", "[SNT Ward /
Borough]='Bedford' ")

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
H

Hammond-Wandsworth

Thank you John - it works. Much appreciated - a pain in the neck alleviated.

John Spencer said:
Try

=DCount("[SNT Ward / Borough]","[Master Table]", "[SNT Ward /
Borough]=""Bedford""")

You need to delimit the string with quote marks. In order to do so, you
need to use a pair of quote marks to end up with one quote mark.

You could also use the apostrophe ' instead of the two quote marks. I
prefer the pair of quote marks since if the name of the Borough contains an
apostrophe it handles that value correctly while the apostrophe solution
would cause an error.

=DCount("[SNT Ward / Borough]","[Master Table]", "[SNT Ward /
Borough]='Bedford' ")

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

Hammond-Wandsworth said:
I'm replicating a DCount sum (that I have used before and which works) in
a
new report control source with a different field from the same table - it
is
now returning #Error in the field box when I run the report. The sum is
exactly the same except the field name and record have changed. Here is
the
new (unworking) syntax:

=DCount("[SNT Ward / Borough]","[Master Table]","[SNT Ward /
Borough]=Bedford")

SNT Ward/ Borough being the field name; Master Table being the table name
and Bedford being the record name. The following is the old code for a
different report that works:

=DCount("[ASBO Began]","[Master Table]","[ASBO Began]=TRUE")

Is anyone able to tell me why this sum isn't working for my new report?
Please help. Thanks.
 

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

Top