You are here:

Using MS Access/How to - Expression to get number of records between two dates

Advertisement


Question
I use Access 2000 and am having trouble getting an expression to work.  It is a membership database with over 12000 member on it.  I produce a report monthly that I have been manually extracting each figure for.  What I want to do is configure a text box in a report to look up a specific field in a specific table and then to count the records that fall between two dates.  For example I want a total number of members that resigned in a given month.  The expression I have been trying is (=dcount [resignationdate], [dbo_members], [resignationdate] =>1/9/2004 and <30/9/2004)

Is this correct or really bad, I can get it to do a greater than or less than or equal to no worries but when I want it between two dates it will not happen.  Can you help.

Resignation date is the field name and dbo_members is the table name.

Thanks
Gill

Answer
=DCount("[Primarykey]","dbo_members","[ResignationDate] Between #1/9/2004# AND #30/9/2004#)

Primary key should be the name of your primary key field. That's what you want to count. You also need the quotes and brackets as I've shown.

HTH
Scott<>

Using MS Access

All Answers


Answers by Expert:


Ask Experts

Volunteer


Scottgem

Expertise

I can answer almost all types of questions relating to Microsoft Access usage and application design. My strengths are database and interface design.

Experience

I've been designing databases for over 15 years working with dBase, FoxPro, Approach and Access.

Organizations
Author of Microsoft Office Access 2007 VBA
Techncial Editor for Special Edition Using Microsoft Access 2007 and Access 2007 Forms, Reports & Queries From Que Publishing

©2012 About.com, a part of The New York Times Company. All rights reserved.