I have a DateTime picker on my form that allows the user to select an "End Date" for how long a record should be written to the database. After having a tester run my program yesterday I was told I should not allow the user to enter an "End Date" that was earlier than the "Start Date". Makes sense.
So this morning I have coded the following.
The MsgBox displays when it should, and the date on the dtPicker changes to today's date, BUT the calander of the dtPicker is still open displaying the original date the user picked. How do I close the calendar part?
I thought the "REFRESH" statement would do it...but nope.
Or is there a better way to do this alltogether??
VB Code:
Private Sub dtEndDate_Change() If dtEndDate.Value < MonthViewClinic.Value Then MsgBox "You cannot select an end date that occurs before the start date", vbInformation, "Invalid Selection" dtEndDate.Value = MonthViewClinic.Value dtEndDate.Year = Year(Now) dtEndDate.Month = Month(Now) dtEndDate.Day = Day(Now) dtEndDate.Refresh Exit Sub End If End Sub




Reply With Quote