By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,426 Members | 3,118 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,426 IT Pros & Developers. It's quick & easy.

Date Validation Rule

P: 1
Could somebody advise please ?:( I've got 2 dates in my Booking table StartHire and EndHire I wont the use Not to be able to input in the EndHire column date which is = or<than StartHire. Any clues would be appreciated.
Thanks in advance.
B
Apr 11 '08 #1
Share this Question
Share on Google+
2 Replies


missinglinq
Expert 2.5K+
P: 3,532
You should always have your data input into the table done thru a form, and in the code module of the form:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_BeforeUpdate(Cancel As Integer)
  2.  If Me.EndDate <= Me.StartDate Then
  3.    MsgBox "End Date Must Occur After Start Date!"
  4.    Cancel = True
  5.    Me.EndDate.SetFocus
  6.  End If
  7. End Sub
Welcome to bytes!

Linq ;0)>
Apr 11 '08 #2

NeoPa
Expert Mod 15k+
P: 31,494
If you want to specify how two (or more) fields within a table relate to each other you can open the Properties window of a table in Design mode and specify your rule in the Validation Rule property there.

In your case I suspect that you'd want :
Expand|Select|Wrap|Line Numbers
  1. [StartHire]<[EndHire]
The Validation Text property can be used to specify an error message if you're not happy with the default one being used.
Apr 11 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.