Thanks Jeff. I have the code from calculating the business days as follows:
Public Function WorkingDays(StartDate As Date, EndDate As Date) As Integer
'....................................................................
' Name: WorkingDays
' Inputs: StartDate As Date
' EndDate As Date
' Returns: Integer
' Author: Arvin Meyer
' Date: February 19, 1997
' Comment: Accepts two dates and returns the number of weekdays between them
' Note that this function does not account for holidays.
'....................................................................
On Error GoTo Err_WorkingDays
Dim intCount As Integer
StartDate = StartDate + 1
'If you want to count the day of StartDate as the 1st day
'Comment out the line above
intCount = 0
Do While StartDate <= EndDate
'Make the above < and not <= to not count the EndDate
Select Case WeekDay(StartDate)
Case Is = 1, 7
intCount = intCount
Case Is = 2, 3, 4, 5, 6
intCount = intCount + 1
End Select
StartDate = StartDate + 1
Loop
WorkingDays = intCount
Exit_WorkingDays:
Exit Function
Err_WorkingDays:
Select Case Err
Case Else
MsgBox Err.Description
Resume Exit_WorkingDays
End Select
End Function
In my table, i have the dates fields that i would like to apply this code
but unsure how to intergrate it into a query. Do i paste this code into a
module and somehow associate it to the query?
Jeff Boyce said:
Your description doesn't indicate what you've already tried and ruled out.
I'll make some assumptions (try posting your actual code/function if my
assumptions are off)...
You have a function that takes two parameters (roughly, StartDate and
EndDate) and calculates the working days between them.
To use that function in a query, you could add a new field
(say, "WorkingDays: =fnYourFunction([YourStartDate],[YourEndDate]")
where you'd enter everything between the quotes (but not the quotes) in a
field "cell" in the query design window, and where you'd substitute the
fields that correspond from your data. This means you'd need to have the
table with those fields selected in the upper half of the query design
window, so Access could see the fields.
--
Regards
Jeff Boyce
www.InformationFutures.net
Microsoft Office/Access MVP
Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/
acss said:
I have been trying to use the code for calculating working days that i placed
in a module but have not had much success. How does one utilize or
insert
the
module in a query so the function will work? I have two fields in the query ,
one for enter date and another recvd date but i am stumped!