megatronixs
Registered User.
- Local time
 - Today, 16:22
 
- Joined
 - Aug 17, 2012
 
- Messages
 - 719
 
Hi all,
 
I found a function to put a next action date into a date field. If in the combobox a status was changed to for example "on client side), then it will know that it has to count 60 days, but not counting the weekends.
The combobox is in a form called "frm_main_hrr" called cmb_status.
for now it will call a intput box and then the results will be put in a message box.
 
How can I adjust it to that when I make a selection in the combobox from status it will put the date in the field "next_action_date"
 
 
	
	
	
		
 
 
code I have now on the combobox:
I hard coded the 60 days in it and the TodayDate as today's date.
	
	
	
		
 
Greetings.
 I found a function to put a next action date into a date field. If in the combobox a status was changed to for example "on client side), then it will know that it has to count 60 days, but not counting the weekends.
The combobox is in a form called "frm_main_hrr" called cmb_status.
for now it will call a intput box and then the results will be put in a message box.
How can I adjust it to that when I make a selection in the combobox from status it will put the date in the field "next_action_date"
		Code:
	
	
	Option Compare Database
Function BusinessDays(stDay As Date, eDay As Integer) As Date
 Dim i As Integer
 Do While i < eDay
 If isWeekend(stDay) = True Then
 i = i + 0
 ElseIf isExclude(stDay) = True Then
 i = i + 0
 Else
 i = i + 1
 End If
 stDay = stDay + 1
 Loop
If isWeekend(stDay) = True Or isExclude(stDay) = True Then
 BusinessDays = BusinessDays(stDay, 1)
 Else
 BusinessDays = stDay
 End If
 End Function
Function isExclude(testDate As Date) As Boolean
 Dim excludeDates(1 To 11) As Date
 Dim intyear As Integer
 intyear = Format(testDate, "YYYY")
 Dim i As Integer
 'Holiday List
 '''''''''''''''''''''''''''''''''''''''''''''
 excludeDates(1) = CDate("1/1/" & intyear) 'New Years Day
 excludeDates(2) = CDate("1/20/" & intyear) '#1/20/2014# 'MLK Jr. Day
 excludeDates(3) = CDate("2/17/" & intyear) '#2/17/2014# 'Presidents' Day
 excludeDates(4) = CDate("5/26/" & intyear) '#5/26/2014# 'Memorial Day
 excludeDates(5) = CDate("7/4/" & intyear) '#7/4/2014# 'Independence Day
 excludeDates(6) = CDate("9/16/" & intyear) '#9/1/2014# 'Labor Day
 excludeDates(7) = CDate("10/13/" & intyear) '#10/13/2014# 'Columbus Day
 excludeDates(8) = CDate("11/1/" & intyear) '#11/11/2014# 'Veterans Day
 excludeDates(9) = CDate("11/27/" & intyear) '#11/27/2014# 'Thanksgiving
 excludeDates(10) = CDate("12/25/" & intyear) '#12/25/2014# 'Christmas
'Missing Government Date – Add Inauguration Day:
 'First January 20 following a Presidential election
For i = 1 To 10
 If testDate = excludeDates(i) Then
 isExclude = True
 Exit Function
 End If
 Next i
 isExclude = False
End Function
Function isWeekend(testDate As Date) As Boolean
 Select Case Weekday(testDate)
 Case vbSaturday, vbSunday
 isWeekend = True
 Case Else
 isWeekend = False
 End Select
 End Function
Function whatDay()
    Dim getDate As Date, getBusDays As Integer
    getDate = InputBox("Start Date")
    getBusDays = InputBox("Business Days")
 
    MsgBox BusinessDays(getDate, getBusDays)
End Function
	code I have now on the combobox:
I hard coded the 60 days in it and the TodayDate as today's date.
		Code:
	
	
	Private Sub cmb_status_AfterUpdate()
Dim TodayDate As Date
Dim BusinessDays As Integer
TodayDate = Date
BusinessDayss = "60"
    getDate = TodayDate
    getBusDayss = BusinessDays
Me.Next_Action_Date = (BusinessDays(getDate, getBusDays))
End Sub
	Greetings.