F
Fatz
I am trying to call the following module (which I borrowed from "The
Access Web") to calculate the number of business days. Here is the
module:
Function Work_Days(BegDate, EndDate) As Integer
' Note that this function does not account for holidays.
Dim WholeWeeks As Variant
Dim DateCnt As Variant
Dim EndDays As Integer
BegDate = DateValue(BegDate)
EndDate = DateValue(EndDate)
WholeWeeks = DateDiff("w", BegDate, EndDate)
DateCnt = DateAdd("ww", WholeWeeks, BegDate)
EndDays = 0
Do While DateCnt < EndDate
If Format(DateCnt, "ddd") <> "Sun" And _
Format(DateCnt, "ddd") <> "Sat" Then
EndDays = EndDays + 1
End If
DateCnt = DateAdd("d", 1, DateCnt)
Loop
Work_Days = WholeWeeks * 5 + EndDays
End Function
'*********** Code End **************
I have a query that has BegDate and EndDate and I want to add a new
column that will call this module and give me the number of business
days. The problem is this...I have never called a module before!!
Can someone please provide me with a detailed explanation of exactly
what needs to be written to get this to work???
Thanks so much!
Chris (Newbie)
Access Web") to calculate the number of business days. Here is the
module:
Function Work_Days(BegDate, EndDate) As Integer
' Note that this function does not account for holidays.
Dim WholeWeeks As Variant
Dim DateCnt As Variant
Dim EndDays As Integer
BegDate = DateValue(BegDate)
EndDate = DateValue(EndDate)
WholeWeeks = DateDiff("w", BegDate, EndDate)
DateCnt = DateAdd("ww", WholeWeeks, BegDate)
EndDays = 0
Do While DateCnt < EndDate
If Format(DateCnt, "ddd") <> "Sun" And _
Format(DateCnt, "ddd") <> "Sat" Then
EndDays = EndDays + 1
End If
DateCnt = DateAdd("d", 1, DateCnt)
Loop
Work_Days = WholeWeeks * 5 + EndDays
End Function
'*********** Code End **************
I have a query that has BegDate and EndDate and I want to add a new
column that will call this module and give me the number of business
days. The problem is this...I have never called a module before!!
Can someone please provide me with a detailed explanation of exactly
what needs to be written to get this to work???
Thanks so much!
Chris (Newbie)