Hi Friends,
I am struggling with a small code.
I have a text box in which date will be entered. I am using the following code to validate and format the date.
I expected it to return error if the date entered is less than Current(System's) date. This is not working. Please help me!
Regards,
Ravi.
I am struggling with a small code.
I have a text box in which date will be entered. I am using the following code to validate and format the date.
Code:
Private Sub txtTDate_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
If IsDate(txtTDate.Value) Or txtTDate.Value > Date Then
sDate = DateSerial(Year(Date), Month(Date), Day(Date))
txtTDate.Value = format(txtTDate.Value, "dd/mm/yyyy")
sDate = txtTDate.Value
Else
MsgBox ("You can't enter past date. Please modify!")
txtTDate.SetFocus
Exit Sub
End If
End Sub
I expected it to return error if the date entered is less than Current(System's) date. This is not working. Please help me!
Regards,
Ravi.