Results 1 to 5 of 5
  1. #1
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496

    dCount by date range

    I have two text fields for date, one from date and one until date, on a form.

    I then have an unbound searching a table

    Code:
    =DCount("NewSchoolsID","tblSchools")
    I need the criteria to sort a few things

    the field CatLabelPrinted is null

    it is within the date range of those two text fields

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Maybe:

    DCount("NewSchoolsID", "tblSchools", "CatLabelPrinted Is Null AND datefield BETWEEN #" & datefrom & "# AND #" & dateto & "#")
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by June7 View Post
    Maybe:

    DCount("NewSchoolsID", "tblSchools", "CatLabelPrinted Is Null AND datefield BETWEEN #" & datefrom & "# AND #" & dateto & "#")
    see I would have stupidly done it like so:

    Code:
    CatLabelPrinted Is Null AND "datefield BETWEEN" # & datefrom & # AND # & dateto & #")
    I am still getting my head around concatenation.

    You encompass the whole of the criteria in " " except the dates which need their own

    I am guessing you have to use #" & datefrom & " # to let it know you want the value inside that field - why it can't be just [DateFrom] is because it isn't a field and unbound?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Actually, I think the domain aggregate needs the delimiters regardless if control is bound. The WHERE CONDITION follows rules of SQL WHERE clause.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Ended up doing this

    works perfectly many thanks June7.

    I need to buy you a beer.

    I ended up using this

    Code:
    =DCount("NewSchoolsID","tblSchools","not isnull(CatalogueLabelPrinted) AND CatalogueLabelPrinted BETWEEN #" & [BeforeDate] & "# AND #" & [AfterDate] & "#")

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 09-11-2013, 09:49 AM
  2. Replies: 3
    Last Post: 07-18-2012, 10:13 PM
  3. Date Range Report with Multiple Date Fields
    By StevenCV in forum Reports
    Replies: 13
    Last Post: 02-29-2012, 08:29 AM
  4. DCount with Date Grouping
    By brunor in forum Reports
    Replies: 2
    Last Post: 09-30-2011, 08:05 PM
  5. Using a date range with Dcount function
    By mleberso in forum Reports
    Replies: 4
    Last Post: 06-17-2011, 08:56 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums