I have a form with 2 combo boxes( start range and end range)
and an update button .
This form will update the charts based on the Start_Range & End_Range values.
Thus , I would like to limit the range to 12 months
but I have no idea how to do it .
Anyone can help with this ?
Thanks in advance
The code below is for the Update button
Code:
Private Sub cmd_Update_Click()
Dim UpdateSQL As String
Dim StartRange, EndRange As Date
On Error GoTo ErrorHandler
If (Me!cboStartRange.ListIndex = "-1" And cboEndRange.ListIndex = "-1") Or (Me!cboStartRange.ListIndex = "-1" Or cboEndRange.ListIndex = "-1") Then
MsgBox "Please select Date Range!", vbOKOnly
Me!cboStartRange.SetFocus
Else
StartRange = CDate(cboStartRange)
EndRange = CDate(cboEndRange)
UpdateSQL = "Update Setting Set Start_Range = '" & StartRange & "', End_Range = '" & EndRange & "' Where Type = 'SUMMARY_RANGE'"
DoCmd.RunSQL UpdateSQL
Me.Refresh
Exit Sub
End If
ErrorHandlerExit:
Exit Sub
ErrorHandler:
MsgBox "Error No: " & Err.Number & " ; Description: " & _
Err.Description
Resume ErrorHandlerExit
End Sub