I have a series of checkboxes, used to classify query criteria, such that you can run a report for 1st Quarter, 2nd Quarter etc, or by year. These are located on a form; however, when choosing a start and end date, I'm wanting to restrict the check box selection such that if your start period is 3rd Quarter of 2007, then your end period can't be 1st Quarter of 2007. Within my code I attempt to put up a messagebox, and cancel the event, which seems to work, unfortunately, though, I cannot click on anything else until I hit the escape key, otherwise it repeats the messagebox every time I click.
Attached image is the form as it looks at the moment, where you have a start and end time period, and The code below is comparing the existing checks and time periods to determine validity.
Attached image is the form as it looks at the moment, where you have a start and end time period, and The code below is comparing the existing checks and time periods to determine validity.
Code:
Private Sub chkE1Qtr_BeforeUpdate(Cancel As Integer)
If (Me.EndYear = Me.YearofForecast And (Me.chk2Qtr = True Or Me.chk3Qtr = True Or Me.chk4Qtr = True)) Then
msgbox ("You may not choose a quarter that precedes your starting quarter. (Ie: End Date must be after Start Date))")
Cancel = True
Else
Me.chkE2Qtr = False
Me.chkE3Qtr = False
Me.chkE4Qtr = False
Me.chkEYr = False
End If
End Sub