Results 1 to 6 of 6
  1. #1
    renrut is offline Novice
    Windows 10 Office 365
    Join Date
    Dec 2020
    Posts
    1

    Concatenate calculated fields

    I am using Access in Office 365 ProPlus. I have a table with access card reads and the field I'm working from is the [date/time] field. With this field, I would like to show the week (so 12/1/2020 would be week 49) and then concatenate fields so I can show the range that the date field falls within (Work Week 49 would be comprised of November 30 to December 4 and would show as "Work Week 49: Nov 30 - Dec 04"



    So far, I can get the work week showing with DatePart("ww",[date/time]), but I can't - for the life of me - figure out how to get it to pull the first work day of this criteria and concatenate to the last day of this criteria. HELP???

    Please note I am a very poor user of Access and only understand the very basics.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    usage:
    calcWeekRangeTxt([datefld])

    Code:
    
     'give any date and get the date that starts the week
    Public Function calcWeekRangeTxt(ByVal pvDate)
    Dim iDow As Integer, iSTARTDAY As Integer
    Dim i As Integer
    Dim vStart, vEnd
    
    
    iSTARTDAY = vbSunday
    'iSTARTDAY = DLookup("[StartOfWeek]", kCFG)     'use the config table value, set by admin
    
    iDow = Format(pvDate, "w")
    Select Case True
       Case IsNull(pvDate)
         'nothing to do
      Case Else
            vStart = DateAdd("d", -(iDow - 1), pvDate)
            vEnd = DateAdd("d", 6, vStart)
            calcWeekRangeTxt = "Week:" & DatePart("ww", pvDate) & " from " & vStart & " to " & vEnd
    End Select
    End Function

  3. #3
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,372
    Given your level of expertise I'm going to suggest that you need to copy the db, compact and then zip it and post a copy here. AFAIC, you are going to need a custom function because of the complexity (multiple values need to be calculated). Just getting

    Work week 49: Mon 01
    seems to require

    "Work week " & datepart("ww",#12/01/2020#) & ": " & Format(weekday(#12/01/2020#,vbMonday),"ddd") & " " & Format(weekday(#12/01/2020#,vbMonday),"mm")
    and that's without getting the month, and that's only for the first day/date

    I may not have the time to write this, but there are a few very good coders here and if you provide a db, they will probably jump on it. I'm supposed to be building living room tables but I drop in on my breaks!
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,127
    I'm supposed to be building living room tables but I drop in on my breaks!
    Hi Micron
    You do seem to have a lot of breaks each day ....
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  5. #5
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,372
    ...because I work for a very lenient boss!
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #6
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,127
    Quote Originally Posted by Micron View Post
    ...because I work for a very lenient boss!
    LOL. Me too!
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

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

Similar Threads

  1. Concatenate Like Fields
    By Dean0_53 in forum Queries
    Replies: 5
    Last Post: 12-14-2018, 06:45 AM
  2. How to concatenate 3 fields?
    By nicoboss in forum Access
    Replies: 9
    Last Post: 11-22-2017, 11:04 AM
  3. Replies: 12
    Last Post: 10-01-2013, 12:59 PM
  4. Concatenate two fields
    By buckwheat in forum Access
    Replies: 8
    Last Post: 06-28-2013, 07:06 AM
  5. Concatenate Fields
    By Njliven in forum Forms
    Replies: 9
    Last Post: 12-21-2012, 08:31 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