Validation Rule

message from gford@dodig.osd.mil on 14 May 2004
Trying to compare two fields called end dates and start
date with a validation rule. I get a SQL syntax error -
"cannot use muliple columns in a column-level CHECK
constraint." I want the valiation rule to prevent me from
entering an end date that is greater than the start date.
 
Dave Ruhl replied to gford@dodig.osd.mil on 14 May 2004
I use this in the StartDate LostFocus Event -

If DateDiff("d", Me.StartDate, Me.EndDate) < 0 Then
MsgBox ("Start Date cannot occur after Date Reported")
Me.StartDate.SetFocus
End If
 
Dirk Goldgar replied to gford@dodig.osd.mil on 14 May 2004
"gford@dodig.osd.mil" <anonymous@discussions.microsoft.com> wrote in
message news:d48401c439c5$20e92f70$a301280a@phx.gbl

Field validation rules can't refer to other fields in the table. You
must use a table validation rule for this. With the table open in
design view, click the Properties button to open the table's property
sheet, and enter a validation rule along these lines:

[EndDate]>=[StartDate] Or [EndDate] Is Null

(using your own field names, of course). Note that I've assumed (a) you
want to prevent the entry of an end date that is *less than*, not
greater than, the start date, and (b) you will allow a record to be
saved that has no end date yet. If those assumptions are wrong, adjust
the validation rule accordingly.
 

Archived message: Validation Rule (MS Access)