By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,650 Members | 1,980 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,650 IT Pros & Developers. It's quick & easy.

Dcount function, return dates in last year in criteria

P: n/a
stroccur = DCount("[cattype]", "empnotes", "[cattype] = " & Chr(34) &
Me.Rpt_Card_Type & Chr(34) & " And [SSN] = " & Me.SSN & " And #" &
[datetime] & "# > " & DateSerial(Year(Me.datetime) - 1,
Month(Me.datetime), Day(Me.datetime)))

I'm using the above function to count similar records that have fallen
in the last year.

Ex:
SSN datetime cattype # of records in last year
23 8/10/04 1 0
23 1/25/04 1 1
23 7/25/04 1 2
23 8/25/05 1 2

The last record entered 8/25/05 should only count 2 records, however
my Dcount function is returning 3. What am I doing wrong?

Thanks
Nov 13 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
If [datetime] is defined as a date type field you probably don't need the #
signs. The # signs are used where the type of the value may be ambiguous to
specify that it should be a date. This is usually on the right side of the
operator (=, >, <) sign.

--
Wayne Morgan
MS Access MVP
"Dan Leeder" <fl*******@excite.com> wrote in message
news:7d**************************@posting.google.c om...
stroccur = DCount("[cattype]", "empnotes", "[cattype] = " & Chr(34) &
Me.Rpt_Card_Type & Chr(34) & " And [SSN] = " & Me.SSN & " And #" &
[datetime] & "# > " & DateSerial(Year(Me.datetime) - 1,
Month(Me.datetime), Day(Me.datetime)))

I'm using the above function to count similar records that have fallen
in the last year.

Ex:
SSN datetime cattype # of records in last year
23 8/10/04 1 0
23 1/25/04 1 1
23 7/25/04 1 2
23 8/25/05 1 2

The last record entered 8/25/05 should only count 2 records, however
my Dcount function is returning 3. What am I doing wrong?

Thanks

Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.