I have a combobox with a list of names that reflect a list of functions. The name of this combobox is [PatchDateFuncti on]. When a specific function name is chosen from that list I want to make [PatchDate] = functionname.
I have a total of 34 functions, each of which calculates various dates. For simplicity I will show two here.
The example method would looks like this if it was hard coded:
The problem is making the function name a variable and how to change the method... Im guessing Ill probably need to create another method but dont know where to begin.
I have a total of 34 functions, each of which calculates various dates. For simplicity I will show two here.
Function First_Saturday( ) As Date
For x = 0 To 6
If Weekday(DateSer ial(Year(Date), Forms![frmDateCalculat ions]![cmbMonthSelect], 1) + x, vbUseSystemDayO fWeek) = vbSaturday Then
First_Saturday = DateSerial(Year (Date), Forms![frmDateCalculat ions]![cmbMonthSelect], 1) + x
End If
Next x
End Function
For x = 0 To 6
If Weekday(DateSer ial(Year(Date), Forms![frmDateCalculat ions]![cmbMonthSelect], 1) + x, vbUseSystemDayO fWeek) = vbSaturday Then
First_Saturday = DateSerial(Year (Date), Forms![frmDateCalculat ions]![cmbMonthSelect], 1) + x
End If
Next x
End Function
Function Second_Thursday _after_First_Tu esday() As Date
For x = 0 To 6
If Weekday(DateSer ial(Year(Date), Forms![frmDateCalculat ions]![cmbMonthSelect], 1) + x, vbUseSystemDayO fWeek) = vbTuesday Then
Second_Thursday _after_First_Tu esday = DateSerial(Year (Date), Forms![frmDateCalculat ions]![cmbMonthSelect], 1) + x + 9
End If
Next x
End Function
For x = 0 To 6
If Weekday(DateSer ial(Year(Date), Forms![frmDateCalculat ions]![cmbMonthSelect], 1) + x, vbUseSystemDayO fWeek) = vbTuesday Then
Second_Thursday _after_First_Tu esday = DateSerial(Year (Date), Forms![frmDateCalculat ions]![cmbMonthSelect], 1) + x + 9
End If
Next x
End Function
The example method would looks like this if it was hard coded:
Private Sub cmbPatchDateFun ction_AfterUpda te()
[PatchDate] = First_Saturday( )
End Sub
[PatchDate] = First_Saturday( )
End Sub
The problem is making the function name a variable and how to change the method... Im guessing Ill probably need to create another method but dont know where to begin.
Comment