DCount returns "0" or "#Error"

  • Thread starter Thread starter NickB
  • Start date Start date
N

NickB

I am trying to use a DCount as a Control Source in a
form. For some reason it is either returning "0" (it
seems to return 0 for all instances when it shoud) or if
it should return a number other than 0 it
returns "#Error". I tried wrapping it in IsError, but
got the same results.

Any ideas?
 
NickB said:
I am trying to use a DCount as a Control Source in a
form. For some reason it is either returning "0" (it
seems to return 0 for all instances when it shoud) or if
it should return a number other than 0 it
returns "#Error". I tried wrapping it in IsError, but
got the same results.

Any ideas?

Please post the actual controlsource expression which returns #Error.
 
NickB said:
=DCount("*","tblMembers","[Forms]![frmAddresses].
[AddressID]=[AddressID]")

I have to ask the obvious questions:

1. Is form "frmAddresses" open?

2. Is there a control named "AddressID" on frmAddresses? Note that I'm
asking about a control with that name, not a field with that name.

3. Is there a field named "AddressID" in tblMembers?

Although the control reference syntax using the bang --

[Forms]![frmAddresses]![AddressID]

is more standard than using the dot --

[Forms]![frmAddresses].[AddressID]

-- I would normally expect that to work.

The control that has this controlsource expression doesn't by any chance
have the same name as a field in the form's recordsource, does it?
 
Thanks! The obvious questions generally pick up the
answers :)

2. I did not have a control with that name on the field.
I did at one point, but deleted it, before adding the
DCount. Since it never produced an error when the answer
was 0, I ASSumed that it wasn't the problem, but you know
what happens when you assume...

Thanks!
 
NickB said:
Thanks! The obvious questions generally pick up the
answers :)

2. I did not have a control with that name on the field.
I did at one point, but deleted it, before adding the
DCount. Since it never produced an error when the answer
was 0, I ASSumed that it wasn't the problem, but you know
what happens when you assume...

I'm not sure why it wouldn't give an error when the answer is 0 -- or
exactly what that means in terms of the exact circumstances -- but I'm
glad we came upon the source of the problem.
 
Back
Top