I have an update form for my project. A message box appears after the user clicks an update button requesting them to confirm the delivery date. A Yes/No message box is displayed here. When the user selects No, an input box where they can type the correct date displays.
The issue I'm encountering is with the data validation that happens after the user-inputted date. I'm trying to make sure the user entered a real date and not just a bunch of alphabetic symbols. This function starts at "Line1" in the code. The Otherwise sentence below "Line1" is where the issue is. If I type a date that is properly typed, the code jumps to the Msgbox before bringing me back to "Line1." I don't get the Message box asking me to change the date if I enter a string of alpha characters; instead, I get a Runtime Error 13 Type Mismatch.
Range("A" & Rows.Count).End(xlUp).Offset(1).Select
iRow = ActiveCell.Row
lastRow = ws3.Cells(ws3.Rows.Count, 1).End(xlUp).Row
For i = 3 To lastRow 'Isolate the Record, Get data, and move
wo = Cells(i, 1).Value
pn = Cells(i, 2).Value
sn = Cells(i, 3).Value
n = Cells(i, 6).Value
If Me.txt_WN.Value = wo Then
If Me.txt_pn.Value = pn Then
If Me.txt_sn.Value = sn Then
If n = "Yes" Then
dd = MsgBox("Is this the correct delivery date? " & Curr, vbYesNo)
If dd = vbYes Then
dd = Curr
Else
Line1: 'Problem exists here
If IsDate(dd = InputBox("Enter the Correct Delivery Date", "Deliver to Stores Date")) Then
dd = Format(dd, "mm/dd/yyyy")
Else
MsgBox "The date is formatted incorrectly, please recheck entry"
GoTo Line1
End If
'If IsDate(dd) Then
' dd = Format(dd, "mm/dd/yyyy")
'Else
' MsgBox "The date is formatted incorrectly, please correct"
' GoTo Line1
'End If
End If
GoTo Update
Else
MsgBox "This Wheel S/N was not marked as Due for NDT"
Exit Sub
End If
End If
End If
End If
Next i
A second if statement that has been commented out can be seen below the first If Statement following "Line1." In such case, pressing the No button on the message box would input "1/7/1900," essentially avoiding the need to enter the code for validation (I think).
I have no idea what is happening. Similar validation code that I used in other subroutines worked perfectly. Any ideas as to where I might be going wrong would be greatly appreciated.