date management

kgray

Registered User.
Local time
Today, 07:50
Joined
Feb 14, 2005
Messages
11
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
 

Attachments

On Got focus Event of Delivery_Date put:

Code:
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
 
Last edited:
thanks

simple when you know how!
cheers
kev
 
ssoltic said:
On Got focus Event of Delivery_Date put:

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
 

Users who are viewing this thread

Back
Top Bottom