Yes, that was the issue. I edited this post. I had another issue, but for whatever reason, it's now working as expected. I'm going to post my end code herein.
I have a table:
Holidays |
11/8/2021 |
11/9/2021 |
11/10/2021 |
Query: SELECT MyCountWorkDays(3,Date()) AS Days;
Today's date happens to be: 11/3/2021.
Query results: 11/11/2021
Code:
Public Function MyCountWorkDays(lngDays As Long, _
Optional dtmDate As Date = 0) As Date
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim lngA As Long
Dim varA() As Variant
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("Holidays", dbOpenDynaset, dbReadOnly)
If rst.EOF = False And rst.BOF = False Then
rst.MoveLast
rst.MoveFirst
ReDim varA(0 To rst.RecordCount - 1) As Variant
lngA = 0
Do While rst.EOF = False
varA(lngA) = rst!Holidays.Value
rst.MoveNext
lngA = lngA + 1
Loop
End If
rst.Close
Set rst = Nothing
dbs.Close
Set dbs = Nothing
MyCountWorkDays = dhAddWorkDaysA(lngDays, dtmDate, varA)
End Function
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
Thank you all for your guidance!