aplfalcon
04-12-2010, 12:21 PM
Hi,
I have two DTPickers in my userform. They will be used to select a date range. I want to write code that will pop-up a message box and prevent the user from continuing if the user selects an end date which is before the start date. For example, if the start date is 4/12/2010, the user cannot select an end date that is 4/11/2010 or earlier.
This is probably horribly wrong (I'm a novice), but here's what I've tried:
' The DTPicker code:
Private Sub EndDatePicker_CallbackKeyDown(ByVal KeyCode As Integer, ByVal Shift As Integer, ByVal CallbackField As String, CallbackDate As Date)
' My Code:
IF EndDatePicker.DateValue("<"&StartDatePicker.Value) THEN
MsgBox "You cannot enter an end date which occurs before the start date."
EndDatePicker.SetFocus
Exit Sub
End If
End Sub
I hope someone can help me. Thanks!
I have two DTPickers in my userform. They will be used to select a date range. I want to write code that will pop-up a message box and prevent the user from continuing if the user selects an end date which is before the start date. For example, if the start date is 4/12/2010, the user cannot select an end date that is 4/11/2010 or earlier.
This is probably horribly wrong (I'm a novice), but here's what I've tried:
' The DTPicker code:
Private Sub EndDatePicker_CallbackKeyDown(ByVal KeyCode As Integer, ByVal Shift As Integer, ByVal CallbackField As String, CallbackDate As Date)
' My Code:
IF EndDatePicker.DateValue("<"&StartDatePicker.Value) THEN
MsgBox "You cannot enter an end date which occurs before the start date."
EndDatePicker.SetFocus
Exit Sub
End If
End Sub
I hope someone can help me. Thanks!