Hey all,
I use this small code to check if the date entered is in the future or not.
If it is the user gets a messagebox and the cell should empty.
Without txtStDate.Value = "" it works. When i added i get error: Type mismatch.
I think because the code runs again when the cells gets emptied.
Someone knows how i can fix this?
I use this small code to check if the date entered is in the future or not.
If it is the user gets a messagebox and the cell should empty.
Code:
Private Sub txtStDate_Change()If CDate(txtStDate.Value) > Date Then
MsgBox "The date of observation is in the future." & vbCrLf & "This is not possible, please correct!"
txtStDate.Value = ""
txtStDate.SetFocus
End If
End Sub
Without txtStDate.Value = "" it works. When i added i get error: Type mismatch.
I think because the code runs again when the cells gets emptied.
Someone knows how i can fix this?