Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Validation Rules 1

Status
Not open for further replies.

AccessStudent

Technical User
Mar 14, 2001
2
0
0
US
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.
 
You should do this on the form, as they are entering data. Try this:

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 &quot;You must enter a date on the 1st of the 15th to continue&quot;
Cancel = True
End If
End Sub
=====
Jim Lunde
compugeeks@hotmail.com
Custom Application Development
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top