DCount function

S

SheldonMopes

I'm having difficulty with the DCount function, not getting the
results that I want.


Field1A and Field2A are fields in TableA matching Field1B and Field2B
in TableB

Using a calculated control in a subform bound to TableB, Field1B and
Field2B are on the form. (Control names are txtField1B and txtField2B)


= DCount("ID", "TableA", "([TableA].[date]=date() AND
[TableA].[Field2A]=[TableB].[Field1B] AND
[TableA].[Field2A]=[TableB].[Field2B])")

I have tried this also using the reference to the controls on the form
as well, but still no good:

= DCount("ID", "TableA", "[TableA].[date]=date() AND
[TableA].[Field1A]=forms!frmSubform1!txtField1B AND
[TableA].[Field2A]=forms!frmSubform1!txtField2B")

What am I doing wrong ? Thanks in advance for any help.
 
T

tina

try

= DCount(1, "TableA", "[date] = #" & Date() & "# And
[Field1A] = '" & txtField1B & "' And [Field2A] = '" & txtField2B & "'")

the above expression assumes that Field1B and Field2B are both Text data
type. if either (or both) is a number, remove the *single* quotes that
surround each non-text value.

btw, the word "date" is a Reserved word in Access; you should not use it as
the name of a field in a table, or as the name of anything else in your
database. suggest you change that field's name in TableA to something else.

hth
 

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