Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datediff without the weekends, NETWORKDAYS

Status
Not open for further replies.

kb178

IS-IT--Management
Aug 16, 2001
83
US
I tried using NETWORKDAYS to get the difference between two dates without the weekends, but it didn't work. So I found FAQ181-261, but I'm not sure what to do with it.

Is the holiday table supposed to be call holiday or tblholiday?
If I have two dates on a report that I'm trying to find the difference between, do I put a third text box and have it call the function? What's the control source? Or is it just supposed to be called Delta Days or Num Days?

Thanks!
 
Something like:


Code:
Private Sub txtEndDt_AfterUpdate()
    Call SetDeltaDays
End Sub

Private Sub txtStartDt_AfterUpdate()
    Call SetDeltaDays
End Sub

Public Sub SetDeltaDays()

    If (Not IsDate(Me.txtStartDt)) Then
        Exit Sub
    End If

    If (Not IsDate(Me.txtEndDt)) Then
        Exit Sub
    End If

    Me.txtDeltaDays = DeltaDays(Me.txtStartDt, Me.txtEndDt)

End Sub

by inspection, you should be able to 'see' the example form includes three text boxes, one for the start date, one for the end date and one for the result. In the start & ene dates, (for the example) you manually enter a (VALID) date. When either of these are updated, they call the routine to calc the diff. If BOTH are dates, the diff is calculated and PLACED into the third text box.

This is not the most elegant use of the procedure or even a decent example, but should at least let you observe the functionallity of a simple procedure call.

MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
What about on a report, though?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top