Hi
I use two DateTimePickers to restrict the results of a data query
I also dont want users to be able to set the StartDate to be After the EndDate.
The problem is that if I use the Value changed, and you change to another month, the ValueChange Event is fired, and this causes my query to run.
Even worse, I am validating the start and end dates on the Value changed event, so in the code below, if the DateTo value was on 3 March, and the From was on 20 Feb, and you change the month of DateFrom to March the value of the DateFrom changes to 20 Mar, and the Query is run TWICE before you have even clicked on the actual day you want to select in The DateFrom box.
Is there a way to only catch the event when an actual day of the month is clicked, and ignore the change while you are selecting the month?
I tried using LostFocus event, but then you have to click another control before the event is fired - not cool.
Private Sub dtpStkHistDateFrom_ValueChanged(sender As System.Object, e As System.EventArgs) Handles dtpStkHistDateFrom.ValueChanged
If Me.dtpStkHistDateFrom.Value > Me.dtpStkHistDateTo.Value Then Me.dtpStkHistDateTo.Value = Me.dtpStkHistDateFrom.Value
GetStkHist()
End Sub
Private Sub dtpStkHistDateTo_ValueChanged(sender As System.Object, e As System.EventArgs) Handles dtpStkHistDateTo.ValueChanged
If Me.dtpStkHistDateTo.Value < Me.dtpStkHistDateFrom.Value Then Me.dtpStkHistDateFrom.Value = Me.dtpStkHistDateTo.Value
GetStkHist()
End Sub