How do I call a FUNCTION

jboyle

New member
Local time
Today, 20:18
Joined
Nov 18, 2000
Messages
53
I have a text box that contains the "Book Date" and another text box that contains the "Run Date". I want a 3rd. text box to calculate the workdays between the "Book Date" and the "Run Date". I have created a function that should calculate the workdays but I don't know where to place the function so that the function places the number of workdays in the 3rd text box. This is the function that I want to call:
********************************************
Function Work_Days(BookDate As Variant, RunDate As Variant) As Integer

Dim WholeWeeks As Variant
Dim DateCnt As Variant
Dim EndDays As Integer

BookDate = DateValue(BookDate)
RunDate = DateValue(RunDate)
WholeWeeks = DateDiff("w", BookDate, RunDate)
DateCnt = DateAdd("ww", WholeWeeks, BookDate)
EndDays = 0
Do While DateCnt < RunDate
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
*******************************************

I thank you in advance for your help.
John J. Boyle
 
You could place it in the AfterUpdate or OnExit event of the 2nd Text box:

TextBox3 = Work_Days(Me!TextBox1, Me!TextBox2)

Should place the value into the textbox
Ian
 

Users who are viewing this thread

Back
Top Bottom