471,066 Members | 2,099 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,066 software developers and data experts.

Dcount function, return dates in last year in criteria

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
1 2741
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.

Similar topics

1 post views Thread by Megan | last post: by
5 posts views Thread by mcbill20 | last post: by
18 posts views Thread by jimfortune | last post: by
5 posts views Thread by turtle | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.