End Date before Start Date VBA

The Last Day

Registered User.
Local time
Today, 17:38
Joined
May 1, 2009
Messages
17
I need help on a VBA module.

I need a message box to pop up to warn the user when the End Date is earlier than the Start date when the End and Start dates are entered into a form.

Help please?
 
Yeah, I definitely need to do it in BeforeUpdate.

This is what I have so far:
Code:
Private Sub EndDate_BeforeUpdate(Cancel As Integer)
    'Warn that the End Date is before the Begin Date
    If Me.EndDate < Me.BeginDate Then
            MsgBox "The End Date is earlier than the Begin Date."
            
    End If
End Sub
I need it to cancel the data entering. How do I do that?
 
That's the

Cancel = True

I used in the link. You can also use Undo if you want.
 
No problem, and welcome to the site by the way!

It may be a style thing, but I generally do all the validation at once in the form's before update event, rather than having code in each textbox. Maybe it's because I deal a lot with data entry people who tend to key in stuff without looking until the end (reading off a piece of paper). A message box popping up in the middle would screw them all up.
 
I'll keep that in mind for my database project. The question above was for a specific problem in a specific form for a specific control. Thanks!
 

Users who are viewing this thread

Back
Top Bottom