Results 1 to 10 of 10
  1. #1
    seb is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jun 2010
    Posts
    73

    Name of the week

    Hello
    I think I have a very basic problem but cannot find any solution.
    I Have googled and searched a lot but no success!

    Also I tried many times Function DatePart, but any time I failed
    In MS Access 2013, I have a Form named Jorns. In Txtbox Dte I write dates. Also I have TxtBok wkk.

    Could someone tell me how to display the week of the year in field wkk any time I write a date in field Dte?


    In my case the first week of the year is the first Monday of the year.

    Many thanks

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    In text box "wkk", maybe try:
    Code:
    = DatePart("ww",Dte,vbMonday)

  3. #3
    seb is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jun 2010
    Posts
    73
    ssanfu
    Hello. I tested the code, does not work.

  4. #4
    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,870
    See this info re DatePart. Pay particular attention to the firstWeekOfYear. See if your requirement fits one of the options.

    Also, does not work does not help. Did you get an error message? Did you get a value that you didn't expect?

  5. #5
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Apparently, Access does not understand "vbMonday".
    Try changing "vbMonday" to 2.
    Code:
    DatePart("ww",Dte, 2)

  6. #6
    seb is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jun 2010
    Posts
    73
    Hello orange.


    According to the Function DatePart, in mycase the firstWeekOfYear is the first week of January
    Now, when I Type
    DatePart("ww",Dte, 2)


    Access change to:
    DatePart("ww";[Dte]; 2)


    Theres is not error message. Also there is no value al all.


    I also tryed this code with no succees


    'Function ww() As String
    ww = Me!Dte & ""
    End Function'


    'Function ww() As String
    ww = Me!Dte & ""
    End Function'


    This code works well in another db Form I designed in Access 2010.



    I am really

    Many thanks for your help

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Quote Originally Posted by ssanfu View Post
    Apparently, Access does not understand "vbMonday".
    Sure it does...in VBA code.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  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,870
    Now, when I Type
    DatePart("ww",Dte, 2)


    Access change to:
    DatePart("ww";[Dte]; 2)


    Theres is not error message. Also there is no value al all.
    Where did you type that?

    The substitution of ";" for "," is because of your regional settings.

    In the immediate window, I type and get

    ?datepart("ww",Date,2)
    42

  9. #9
    seb is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jun 2010
    Posts
    73
    Hello
    I Typed in "On Click" in Field ww of the Form

  10. #10
    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,870
    Type your code into the immediate window. And see if there is an answer.

    Start the line with ? which indicates Print the value.

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. Replies: 26
    Last Post: 11-05-2015, 01:58 PM
  3. Replies: 9
    Last Post: 06-19-2015, 03:37 PM
  4. Replies: 1
    Last Post: 01-28-2015, 12:19 PM
  5. Replies: 3
    Last Post: 09-19-2013, 10:18 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