Results 1 to 11 of 11
  1. #1
    Brightspark98 is offline Advanced Beginner
    Windows 7 64bit Access 2013 64bit
    Join Date
    Dec 2016
    Posts
    57

    Week Number


    Click image for larger version. 

Name:	DATE.png 
Views:	14 
Size:	44.6 KB 
ID:	27026
    Can anyone provide the code or help, I want to enter the date in the upper box and the lower box reveals the week number for the selected date.

    Many Thanks.

  2. #2
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    I seem to remember

    DatePart("ww", Me.thedate)

    Assuming your date box is called thedate


    Sent from my iPhone using Tapatalk

  3. #3
    Brightspark98 is offline Advanced Beginner
    Windows 7 64bit Access 2013 64bit
    Join Date
    Dec 2016
    Posts
    57
    Thanks this works great, but how do I get the textbox - 'txtWeek' to auto-update. The week number only appears when I click on the textbox.

  4. #4
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051

    Week Number

    Change the on_update event of the year textbox to

    Me.recalc()


    Sent from my iPhone using Tapatalk

  5. #5
    Brightspark98 is offline Advanced Beginner
    Windows 7 64bit Access 2013 64bit
    Join Date
    Dec 2016
    Posts
    57
    I must be going wrong somewhere still only changes when selected.

  6. #6
    Brightspark98 is offline Advanced Beginner
    Windows 7 64bit Access 2013 64bit
    Join Date
    Dec 2016
    Posts
    57
    This is the code I am using...

    Private Sub thedate_AfterUpdate()
    Me.txtWeek = DatePart("ww", Me.thedate)
    End Sub

    Private Sub txtWeek_AfterUpdate()
    Me.Recalc()
    End Sub

  7. #7
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    In design mode add me.txtweek= etc as the controlsource of your week textbox. That should do it. And you shouldn't need the vba code you have


    Sent from my iPhone using Tapatalk

  8. #8
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722

  9. #9
    Brightspark98 is offline Advanced Beginner
    Windows 7 64bit Access 2013 64bit
    Join Date
    Dec 2016
    Posts
    57
    Thats where i put it at the first attempt, But the week number still only appears when I click in the textbox.

  10. #10
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    I've tested this and it does work (sorry was nowhere near a computer before)

    My date box was called update_date. You'll have to change it.


    Paste this in the form class you are using as the _change event for the date field

    Code:
    Private Sub update_date_Change()
    Me.Recalc
    End Sub


    This code can be pasted into the control source for the weekbox
    Code:
    =DatePart("ww",[update_date])

  11. #11
    Brightspark98 is offline Advanced Beginner
    Windows 7 64bit Access 2013 64bit
    Join Date
    Dec 2016
    Posts
    57
    Excellent.

    thank you very much.

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

Similar Threads

  1. Replies: 2
    Last Post: 04-14-2016, 06:30 PM
  2. week number sorting
    By sdel_nevo in forum Queries
    Replies: 2
    Last Post: 01-13-2016, 09:22 AM
  3. Replies: 9
    Last Post: 06-19-2015, 03:37 PM
  4. Week number - How do you reset?
    By BillG in forum Queries
    Replies: 11
    Last Post: 09-13-2012, 04:41 PM
  5. Week number wrong
    By Nikki17 in forum Queries
    Replies: 6
    Last Post: 03-18-2006, 10:01 PM

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