Maybe I am not doing this correctly or its just not possible. I am hoping someone has a solution. I have a text box that has date time data. It is the first field accessible control on the screen. I validate this field in a validating event. I also have a button for a calendar pop up that allows the user to select a date. I want to validate unless the user Clicks on the calendar button. The issue is I don't know how to tell if the user clicked the calendar button so I can skip the validate until they have selected a date. I am thinking somewhere the program has to know where I clicked on the screen in case there is no errors it will move the cursor to that control. Just don't know how to access where it is stored.

Name:  ServiceRequest.jpg
Views: 327
Size:  36.6 KB

Code:
    Private Sub tbCalled_Validating(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles tbCalled.Validating

        If tbStatus_Key.Text <> Save_StatusKey Then Exit Sub

        If sender.name = "btnCalled" Then  <--- This what I am trying to do
            Exit Sub                                     <---
        ElseIf String.IsNullOrEmpty(tbCalled.Text) Then
            MsgBox("Called date must be a valid date") 'Is required
            tbCalled.Text = Save_Called
            tbCalled.Focus()
            Exit Sub
        ElseIf tbCalled.Text = Save_Called Then
            Exit Sub 'No Change exit
        ElseIf Not IsDate(tbCalled.Text) Then
            MsgBox("Called date must be a valid date")
            tbCalled.Text = Save_Called
            tbCalled.Focus()
        End If

        Dim MyDate As DateTime = DateTime.Parse(tbCalled.Text)
        Dim MyDate2 As DateTime = dtpLogDate.Value
        If MyDate < MyDate2 Then
            MsgBox("Call must be after Error Date")
            tbCallBack.Text = tbCalled.Text
            tbCallBack.Focus()
            Exit Sub
        End If

        MyDate = DateTime.Parse(tbCalled.Text)
        tbCalled.Text = MyDate.ToString("M/d/yyyy h:mm tt")

    End Sub