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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I restricting date input to only Sunday

Status
Not open for further replies.

PCX

Technical User
Dec 17, 2000
54
US
I have a form that the user needs to enter a date. This date always needs to be a SUNDAY. How do I restrict the entry to only Sunday or at least give an error message and take the user back to the Date Field to retry.

I tried to create a table that had ONLY sunday dates but when linked to it, all the dates come up and I have to scroll down three years of dates to get the one I want.

Thanks,
PCX
 
Try the weekday capability of the DatePart function. By default it will return '1' if the date is a Sunday.

Dave
 
Working with what neufarth wrote, I would try something in the Before Update Event:

Private Sub CategoryName_BeforeUpdate(Cancel As Integer)
If (VariableWithDatePart) <> 1 Then
MsgBox &quot;Enter a Sunday or else ...&quot;
Me!DateField.SetFocus
Else
Me!YourNextField.SetFocus
End If
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top