Results 1 to 10 of 10
  1. #1
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    727

    count # for current week

    All, using 2010. I have a report which includes a date field [CallsRecd]. I need to count the #of calls for the current week. Sample Data to illustrate:


    Code:
    Calls
    ID    CallsRecd        
    1     8/8/2014        
    2     8/8/2014        
    3     8/15/2014        
    4     8/14/2014        
    5     8/15/2014
    This is what I need to return
    Code:
     Count  Calls Rec
    3
    I have a current report but I don't want to group on the CallRecd field because the report is grouped on another field. I tried using in the report detail the dcount function but receiving syntax errors. Help Pls

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,952
    If you run the report on Monday morning, is the 'current week' you want really the week ending Sunday the day before?

    Is this report for the 'current week' only? How are you filtering the records?
    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
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    727
    The report is run every Friday afternoon after data entry cutoff time. The report is filtered by date on a form.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,952
    Options for filtering:

    1. calculate the week begin and end date range based on the date on form and use BETWEEN AND operator on the CallsRecd field

    2. calculate a week number or week end date for each record in query and apply filter criteria to that constructed field, criteria would be calculated week number or week end date of the date on form
    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
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    727
    I thought the report had some built in options without using the query like a calculation on the report to get the current week and counting the results. Ok. I used this to calculate the week:

    Code:
    Expr1: DatePart("ww",[Calls Recd])
    Now; you say "appy filter criteria to that constructed field, criteria would be calculated week number or week end date of the date on form"? I already have date filter for the report. I don't want to filter but only want to count the records for the current week. The user needs the other weeks on the report?? Maybe Im missing something??

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,952
    Okay, then apply filter in expression on report, maybe:

    =Count(IIf([Expr1]=DatePart("ww",[date from form]),1,Null))

    or

    =Sum(IIf([Expr1]=DatePart("ww",[date from form]),1,Null))
    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.

  7. #7
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    727
    This gives me dates within the current week without calculating the week number first:
    Code:
    DatePart("ww",[Calls Recd])=DatePart("ww",Date()) And Year([Calls Recd])=Year(Date())
    I tried to get a count of the total records with:
    Code:
    =count(iif(DatePart("ww",[Calls Recd])=DatePart("ww",Date()) And Year([Calls Recd])=Year(Date()))
    I get wrong number of arguments

  8. #8
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    727
    Ok. I got what I needed by using this formula in my query and then applying it to my report as a calculated field:
    Code:
    ThisWeek: DatePart("ww",[CallsRecd])=DatePart("ww",Date()) And Year([CallsRecd])=Year(Date())
    The only problem is that when a date is in the current week; it returns -1 I guess equal to Yes. I need it in the report as a 1 so when I use this calculated field; it returns a whole number:
    Code:
    =Sum([ThisWeek])
    Right now; this returns -3 instead of 3. Thanks

  9. #9
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,952
    Could wrap expression in Abs() function to always return a positive.
    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.

  10. #10
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    727
    For some reason this works: =Sum([ThisWk]*-1) Thanks for all your help

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

Similar Threads

  1. Count number of occurences by day of week??
    By losingmymind in forum Queries
    Replies: 3
    Last Post: 09-19-2013, 06:21 PM
  2. Replies: 3
    Last Post: 09-19-2013, 10:18 AM
  3. Parameter Value = Monday of the current week VBA
    By bcn1988 in forum Programming
    Replies: 4
    Last Post: 09-13-2013, 10:35 AM
  4. Start a report on week 40 of a week count
    By aspitalnick in forum Reports
    Replies: 8
    Last Post: 11-28-2012, 04:53 PM
  5. Replies: 4
    Last Post: 01-23-2012, 08:21 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