N
nziese
I have created a report from a query. In a text box in the summary area I
need to calculate workdays. I have written a VB function to do this. How do
I then use the function in the report to generate the number?
I have tried using the following for the control source the the text box
named WORKDAYS.
=Business_Days_Between_Dates(START_DATE,STATUS_DATE)
START_DATE AND STATUS_DATE ARE TEXT BOXES IN THE REPORT bound to data from
the query.
This is my function
Function Business_Days_Between_Dates(start_date As Date, end_date As Date)
As Integer
Dim counter As Integer
Dim total As Integer
Dim starting_date As Date
Dim ending_date As Date
Dim working_date As Date
Dim daynum As Integer
begin
counter = 1
total = 0
If Not start_date Is Null And Not end_date Is Null Then
ending_date = CDate(end_date)
starting_date = CDate(start_date)
If starting_date = ending_date Then
total = 0
Else
working_date = ending_date - 1
Do While working_date <> starting_date
daynum = Weekday(working_date)
If daynum > 1 And daynum < 7 Then
counter = counter + 1
End If
working_date = working_date - 1
Loop
total = counter
End If
Else
total = -1
End If
Business_Days_Between_Dates = total
End Function
Which is saved as a module. When I run the report I am prompted for an
input for Buseness_Days_Between_Dates. I'm sure it is because I don't know
how to do this. Anyone able to help?
need to calculate workdays. I have written a VB function to do this. How do
I then use the function in the report to generate the number?
I have tried using the following for the control source the the text box
named WORKDAYS.
=Business_Days_Between_Dates(START_DATE,STATUS_DATE)
START_DATE AND STATUS_DATE ARE TEXT BOXES IN THE REPORT bound to data from
the query.
This is my function
Function Business_Days_Between_Dates(start_date As Date, end_date As Date)
As Integer
Dim counter As Integer
Dim total As Integer
Dim starting_date As Date
Dim ending_date As Date
Dim working_date As Date
Dim daynum As Integer
begin
counter = 1
total = 0
If Not start_date Is Null And Not end_date Is Null Then
ending_date = CDate(end_date)
starting_date = CDate(start_date)
If starting_date = ending_date Then
total = 0
Else
working_date = ending_date - 1
Do While working_date <> starting_date
daynum = Weekday(working_date)
If daynum > 1 And daynum < 7 Then
counter = counter + 1
End If
working_date = working_date - 1
Loop
total = counter
End If
Else
total = -1
End If
Business_Days_Between_Dates = total
End Function
Which is saved as a module. When I run the report I am prompted for an
input for Buseness_Days_Between_Dates. I'm sure it is because I don't know
how to do this. Anyone able to help?