Hi. Please see the attached modified version of your database. Open Form1 and play with it. I only did the Daily and Bi-Weekly options. I am hoping you'll be able to adapt what I did to the other intervals. Besides, you might decide this is not what you wanted to do, so I didn't want to change too much. Cheers!Sure, sorry to be a pain in the a**. I truly appreciate your help.
Attached for your review. Thanks![]()
Hi. Please see the attached modified version of your database. Open Form1 and play with it. I only did the Daily and Bi-Weekly options. I am hoping you'll be able to adapt what I did to the other intervals. Besides, you might decide this is not what you wanted to do, so I didn't want to change too much. Cheers!
Edit: By the way, I assumed you didn't want to create a meeting on a Holiday, so I excluded those.
Let us know how it goes...
Case "Monthly"
Do While dteEvent <= EndDate
.AddNew
!MeetingType = Me.cmboMeetingType
!Description = Me.txtMeetingName
!MeetingDate = dteEvent
!MeetingStartTime = Me.txtStartTime
!MeetingEndTime = Me.txtEndTime
!Location = Me.cmboLocation
!Video = Me.chkAV
!CreatedBy = Me.txtCreatedBy
!CreatedDate = Me.txtCreatedDate
!Comments = Me.txtComments
!Host = Me.cmboHost
.Update
StartYear = DatePart("yyyy", Me.cboStart)
Counter = DatePart("mm", !MeetingDate)
MonthlyEvent = Counter + 1
dteEvent = "# & MonthlyEvent & / me.cmboDays / StartYear #"
Loop
Public Function GetNthWeekdayOfMonth(DayIndex As Long, DayOfWeek As Long, DateOfMonth As Date) As Variant
'thedbguy@gmail.com
'2/4/2019
'Returns the nth weekday of the month
'Parameters: DayIndex = 1 to 5, DayOfWeek = 1 to 7 (Sun to Sat), DateOfMonth = any date within the month of interest
'Usage: To return the 4th Monday in February
'GetNthWeekdayOfMonth(4,2,#2/14/2019#)
'Returns: 2/25/2019
'Note: A day index of zero (0) or less will return the 1st date
'and an index of 5 or greater will return the "last" date with a matching weekday
Dim dteNthDate As Date
'set up
If DayIndex <= 4 Then
dteNthDate = DateSerial(Year(DateOfMonth), Month(DateOfMonth), 1)
Else
dteNthDate = DateSerial(Year(DateOfMonth), Month(DateOfMonth) + 1, 0)
End If
'get first ocurrence of date
Do While Weekday(dteNthDate) <> DayOfWeek
If DayIndex <= 4 Then
dteNthDate = DateAdd("d", 1, dteNthDate)
Else
dteNthDate = DateAdd("d", -1, dteNthDate)
End If
Loop
'get nth date
If DayIndex >= 1 And DayIndex <= 4 Then
dteNthDate = DateAdd("ww", DayIndex - 1, dteNthDate)
End If
GetNthWeekdayOfMonth = dteNthDate
End Function