Counting

G

Guest

I have a table with a field named 'memodate'. I'm trying to count them by
year so I can say we have 100 that are 1 year old, 350 that are 2 years old,
etc.. My source code is:
=DCount("[memodate]","tbl-bond","(datediff,y,now,memodate)") but it does not
work. Can anyone offer help??

Thanks
William
 
J

John Vinson

I have a table with a field named 'memodate'. I'm trying to count them by
year so I can say we have 100 that are 1 year old, 350 that are 2 years old,
etc.. My source code is:
=DCount("[memodate]","tbl-bond","(datediff,y,now,memodate)") but it does not
work. Can anyone offer help??

Thanks

You'll need a completely different approach here, William.

I'd suggest creating a Query with a calculated field:

YearsOld: DateDiff("yyyy", [memodate], Date())

Select the Primary Key field of the table into the query; make it a
Totals query using the Greek Sigma icon. Group By YearsOld and select
Count on the primary key field.

John W. Vinson[MVP]
 
G

Guest

John, Hi I put together a query but don't understand. I have a this field
with dates in it. I want to count the dates and seperate them by year but
don't understand the "where" in the VBA code. I entered this thinking OK, I
have it counting the info 6 times now I use "where statements to make it
work....

SELECT Count([tbl-Offsites].datemodified) AS Count1,
Count([tbl-Offsites].datemodified) AS Count2,
Count([tbl-Offsites].datemodified) AS Count3,
Count([tbl-Offsites].datemodified) AS Count4,
Count([tbl-Offsites].datemodified) AS Count5,
Count([tbl-Offsites].datemodified) AS Count6
FROM [tbl-Offsites];
WHERE ("dateModified","tbl-Offsites","DateDiff('yyyy', datemodified,
Now)=0")));

would get me anything for 2006, another 'where' statement for 2005 and so
on. Do I have to create 6 queries???

Thank You
Wm.

John Vinson said:
I have a table with a field named 'memodate'. I'm trying to count them by
year so I can say we have 100 that are 1 year old, 350 that are 2 years old,
etc.. My source code is:
=DCount("[memodate]","tbl-bond","(datediff,y,now,memodate)") but it does not
work. Can anyone offer help??

Thanks

You'll need a completely different approach here, William.

I'd suggest creating a Query with a calculated field:

YearsOld: DateDiff("yyyy", [memodate], Date())

Select the Primary Key field of the table into the query; make it a
Totals query using the Greek Sigma icon. Group By YearsOld and select
Count on the primary key field.

John W. Vinson[MVP]
 

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