DCount function - have I beaten Microsoft ?

GeoffT

Registered User.
Local time
Today, 14:08
Joined
Feb 2, 2005
Messages
14
I have a table [DateToFrom], with three fields [ID],[DateFrom] and [DateTo].

I have a table [Teas] with two fields [ID] and [Date].

I wanted to count the number of records in the table [Teas] between two dates, and show the result on a report.

I created a report [TeasReport] with it's source table [DateToFrom] and I put the fields [DateFrom] and [DateTo] in the report header.

I then put a text box in the report [TeasReport] footer and defined it's source as :-

=DCount("[ID],"Teas","[ID]>0")​

This worked well for total records but I needed the criteria between dates.

And so, playing around, I tried :-

=DCount("[ID],"Teas","[Date]Between[DateFrom]and[DateTo]")​

This worked very well, and I was happy - until I read the Microsoft help document on the DCount function, which states quite clearly " Any field that is included in criteria must also be a field in domain"


My syntax, which works well, seems to go against this rule as :-
"Teas" is the domain name
[Date] is a field within the "Teas" domain​
But :-
[DateFrom] and [DateTo] which I have included in the criteria are fields in the report source table, but are not within the "teas" domain.​



As I say, this is working well, but given that it seems to go against the rules can anyone advise if anything might come out of the woodwork to bite me later on ?
 
The FIELD which the criteria is given needs to be in the domain. NOT the actual DateFrom and DateTo. That can be provided by typing in as paramters, or from a form, etc.
 
Additional - Also, I moved this to the General section from the Site Suggestions Category (which was definitely not the place for this question).
 

Users who are viewing this thread

Back
Top Bottom