Results 1 to 8 of 8
  1. #1
    perryc is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2019
    Posts
    122

    Week Number in Report

    Another seems simple, but with dummy VBA person like me, not sure how to do.



    So, I have a set of dates (e.g. 4/10-16, 4/17-23 & 4/24-30). How can I display a Week1, Week2, Week3 in the Access reports?



    Click image for larger version. 

Name:	Capture.PNG 
Views:	14 
Size:	4.1 KB 
ID:	47649

    Ty again.

  2. #2
    Join Date
    Apr 2017
    Posts
    1,792
    The easiest way (I think):
    Create a Calendary table, which contains all dates from some start date and into some reasonable future. Into this Calendary table you can add various additional info about date - e.g. week number (My advice is to have the week number in format yyyyww).
    In your report source, you join this calendary table with your datasource - then you can have week numbers matching with dates in your report.

  3. #3
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    Those are date ranges, not dates, so I guess datepart("ww",date) or format(date,"ww") won't work for you. Some years will return week 53, which you can work around, and probably will have to do so in a table as well.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    perryc is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2019
    Posts
    122
    Ty both. Actually, I had a initial startdate as well. So, I guess, something like this may give me the week numbers? It seems very complicated though. Is there an easier coding?

    =IIf([DateAssigned] is between [StartDay]+6 and [StartDate]+13,"Wk1"...) This will last for 10wks, and it could be cumbersome to write this whole formula out. Any better suggestions?

  5. #5
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    Best to always show some data and sometimes even better to show expected result. No one has any real idea about what [StartDay] data looks like.
    Why not just datepart("ww",date) where date is a valid date and not the date function? Regardless it would be Between, not Is Between.
    Not understanding how the expression can last for 10 weeks.

    If you've got something complicated going on, might be better to use a table as suggested, but I haven't seen anything here that indicates any complexity.
    Last edited by Micron; 04-08-2022 at 09:20 AM. Reason: added comment
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #6
    perryc is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2019
    Posts
    122
    You guys are wonderful!! ty very much. This works for me.

  7. #7
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    Quote Originally Posted by perryc View Post
    This works for me.
    You're welcome, but what is "this"? Posting your solution is always a good thing in that it helps others who have the same issue and end up looking here.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  8. #8
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    I'd probably create my own function to parse that format, convert to dates and return a week number.
    Hopefully the start date week is not different to end date week?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

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

Similar Threads

  1. Replies: 9
    Last Post: 10-05-2021, 09:04 AM
  2. Replies: 2
    Last Post: 04-14-2016, 06:30 PM
  3. Replies: 9
    Last Post: 06-19-2015, 03:37 PM
  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. Form to Filter Report by Week Number
    By jortizz in forum Forms
    Replies: 1
    Last Post: 05-18-2011, 09:30 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