Hi
i have 2 fields
order date and delivery date using a calender operation
does anyone know how to make it so that the delivery date cannot be sellected on a date before the order date?
cheers
kev
If Delivery_Date.Value = Null Then Exit Sub
If Delivery_Date.Value < Order_Date.Value Then
MsgBox ("Wrong Date") 'Here you can put warning like I do or whatever you want
End If
It's a safer practice to use the form's BeforeUpdate event as that way you can trap the potential error lying in wait that ssoltic has advised.
The validation will only take place if the focus moves to the Delivery_Date textbox. What happens when the person puts in the Order_Date then the Delivery_Date and then realised that the Order_Date has been input incorrectly. When they change the Order_Date the validation is no longer valid and there's no method in place to check.
Hence the BeforeUpdate event. It actually prevents the form from being saved until the data is correct.
Code:
If Me.Delivery_Date. < Me.Order_Date Then
MsgBox ("Wrong Date")
Cancel = True
End If