Date Validation

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I hv two date fields [daterec] and [dateapprov],

How to put control in a form so that [dateapprov] must not be later than
[daterec]

Thanks
 
Zyus,

From your question I assume that [DateApprov] is entered *before* [DateRec],
i.e. approval is required *before* [dateRec] can be entered and if there is
no approval ([DateApprov]=Null), [DateRec] cannot be entered.

If this is the case, use the BeforeUpdate event of *[DateRec]*

Private Sub DateRec_BeforeUpdate()

If IsNull(Me.DateRec) then
Exit Sub
ElseIf IsNull(Me.dateApprov) then
MsgBox "Approval Date must be entered first"
DoCmd.CancelEvent
ElseIf Me.DateRec < Me.DateApprov then
MsgBox "DateRec must be equal or later then Approval Date"
DoCmd.CancelEvent
End If

End Sub

Regards/JK
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top