Date Validation Rules
Date Validation Rules
(OP)
This may seem very basic, but I'm learning...Here's the question:
How do I code a validation rule at Table level or in VB to check if a date typed in by a user is either the 1st of the month or the 15th of the month?
Also how do I check what day it falls on? Example: the 1st of January fall on a Saturday.
How do I code a validation rule at Table level or in VB to check if a date typed in by a user is either the 1st of the month or the 15th of the month?
Also how do I check what day it falls on? Example: the 1st of January fall on a Saturday.
RE: Date Validation Rules
Put this code on the BeforeUpdate Event of your date field.
This is assuming your text field is named txtDate
=====
Private Sub txtdate_BeforeUpdate(Cancel As Integer)
Dim intDay As Integer
intDay = DatePart("d", Me.txtdate)
If intDay <> 1 And intDay <> 15 Then
MsgBox "You must enter a date on the 1st of the 15th to continue"
Cancel = True
End If
End Sub
=====
Jim Lunde
compugeeks@hotmail.com
Custom Application Development