Hello all,
I'm experiencing a lack of knowledge on my side again...
I've borrowed a piece of code from http://access.mvps.org/access/datetime/date0012.htm.
There is an array mentioned for holidays. These holidays however are depending on the country where the supplier is based.
Basically, the dates that need to be in the array are dictated by supplier code:
Supplier Code in Document Master Table
provides Country Code based on Supplier Master Table
provides Holidays from Holiday Master Table based on Country Code
How do I need to build my expression in a way that the correct holidays are taken in to account in the dhAddWorkDaysA function?
I currently have below:
I'm experiencing a lack of knowledge on my side again...
I've borrowed a piece of code from http://access.mvps.org/access/datetime/date0012.htm.
Code:
' ********* Code Start **************
'
' Modified from code in
' "Visual Basic Language Developer's Handbook"
' by Ken Getz and Mike Gilbert
' Copyright 2000; Sybex, Inc. All rights reserved.
'
Public Function dhAddWorkDaysA(lngDays As Long, _
Optional dtmDate As Date = 0, _
Optional adtmDates As Variant) As Date
' Add the specified number of work days to the
' specified date.
' Modified from code in
' "Visual Basic Language Developer's Handbook"
' by Ken Getz and Mike Gilbert
' Copyright 2000; Sybex, Inc. All rights reserved.
' In:
' lngDays:
' Number of work days to add to the start date.
' dtmDate:
' date on which to start looking.
' Use the current date, if none was specified.
' adtmDates (Optional):
' Array containing holiday dates. Can also be a single
' date value, if that's what you want.
' Out:
' Return Value:
' The date of the working day lngDays from the start, taking
' into account weekends and holidays.
' Example:
' dhAddWorkDaysA(10, #2/9/2000#, Array(#2/16/2000#, #2/17/2000#))
' returns #2/25/2000#, which is the date 10 work days
' after 2/9/2000, if you treat 2/16 and 2/17 as holidays
' (just made-up holidays, for example purposes only).
' Did the caller pass in a date? If not, use
' the current date.
Dim lngCount As Long
Dim dtmTemp As Date
If dtmDate = 0 Then
dtmDate = Date
End If
dtmTemp = dtmDate
For lngCount = 1 To lngDays
dtmTemp = dhNextWorkdayA(dtmTemp, adtmDates)
Next lngCount
dhAddWorkDaysA = dtmTemp
End Function
There is an array mentioned for holidays. These holidays however are depending on the country where the supplier is based.
Basically, the dates that need to be in the array are dictated by supplier code:
Supplier Code in Document Master Table
provides Country Code based on Supplier Master Table
provides Holidays from Holiday Master Table based on Country Code
How do I need to build my expression in a way that the correct holidays are taken in to account in the dhAddWorkDaysA function?
I currently have below:
Target Date: IIf([TBL_Source_Document_Upload_Margin]![Workday / Calendarday]="workdays";dhAddWorkDaysA([TBL_Source_Document_Upload_Margin]![Margin (days)];IIf([TBL_Source_Document_Upload_Margin]![Departure/arrival]="Departure";[Tbl_Master_CP201]![Departure Date];[TBL_Master_CP201]![Actual Date for END]); "Holidays to be added in array here");IIf([TBL_Source_Document_Upload_Margin]![Workday / Calendarday]="days";DateAdd("d";[TBL_Source_Document_Upload_Margin]![Margin (days)];IIf([TBL_Source_Document_Upload_Margin]![Departure/arrival]="Departure";[Tbl_Master_CP201]![Departure Date];[TBL_Master_CP201]![Actual Date for END]))))
Last edited: