due dates skipping weekends

jaybo

Registered User.
Local time
Today, 11:56
Joined
Jun 15, 2005
Messages
16
I have a combo box that when selected autofills a due date box. I forgot
that I needed to skip weekends and only count business day. For example if
you choose standard it adds 2 days to the date but I need it to skip
weekends. Any help would be greatly appreciated.

Private Sub YourComboName_AfterUpdate()
Dim intDays As Integer
Select Case Me.YourComboName
Case "Standard"
intDays = 2
Case "Sensitive"
intDays = 5
Case Else
intDays = 10
End Select
Me.YourDateTxtbox = DateAdd("d", intDays, Date)
End Sub
 
The code below should do the trick, just modify it to suit your needs. In my form a have 1 drop down list and 2 text boxes. If the date to ship falls on a saturday or Sunday the textbox showing the Dateminus weekend will show the valid date accounting for the weekend day. This article has a very good reference to using the date and all its properties. I highly recommend it. The attached databse is in Access 2002, 2003 format.

http://www.developershandbook.com/Downloads/2162ch03.pdf

Private Sub cmbType_AfterUpdate()
Dim intDays As Integer
Dim TempDate As String
Me.txtDuedateweekend = Null

Select Case Me.cmbType
Case "Standard"
intDays = 2
Case "Sensitive"
intDays = 5
Case Else
intDays = 10
End Select
Me.txtDuedateNormal = DateAdd("d", intDays, Date)

TempDate = Weekday(txtDuedateNormal, vbSunday)

If TempDate = vbSaturday Then
Me.txtDuedateweekend = DateAdd("d", intDays + 2, Date)
End If

If TempDate = vbSunday Then
Me.txtDuedateweekend = DateAdd("d", intDays + 1, Date)
End If

End Sub
 

Attachments

Thanks for the help I really appreciate it Im not much of a DB designer sorta of forced into it for this project

I seem to have on glitch two day and 5 days work fine but the third case of 10 includes the weekend in its calcualtion ex June 16 results in june 28 due when it should be june 30 b/c its counting the one weekend before any ideas?. and did you modifiy your to exclude holidays ?

Thanks alot
 

Users who are viewing this thread

Back
Top Bottom