Hi,
I'm trying to create validation for date field.
As it stands, the validation makes sure the date is in the correct format, but it allows you to enter past dates.
I need the date to be in the dd/mm/yyyy format and the date should be today or greater. No past dates.
Can anyone help?
This is the code i have so far:
If IsDate(startDate.Value) Then
If Format(startDate, vbLongDate) >= Format(Date, vbLongDate) Then
startDate = Format(startDate, "dd/mm/yyyy")
Else
MsgBox "The date you entered is in the past."
Cancel = True
End If
Else
MsgBox "The date entered is in an invalid format, please enter the date in DD/MM/YYYY format"
Cancel = True
End If
I'm trying to create validation for date field.
As it stands, the validation makes sure the date is in the correct format, but it allows you to enter past dates.
I need the date to be in the dd/mm/yyyy format and the date should be today or greater. No past dates.
Can anyone help?
This is the code i have so far:
If IsDate(startDate.Value) Then
If Format(startDate, vbLongDate) >= Format(Date, vbLongDate) Then
startDate = Format(startDate, "dd/mm/yyyy")
Else
MsgBox "The date you entered is in the past."
Cancel = True
End If
Else
MsgBox "The date entered is in an invalid format, please enter the date in DD/MM/YYYY format"
Cancel = True
End If