Quote:
Originally Posted by JC21
I have a couple of questions about date restrictions.
On one of my forms in my DB I have the MS calendar. The question I have is how do I prevent the user from selecting a date in past and from selecting no more than 45 days into the future. Example today is 12/08/06, I would like to prevent the user from selecting 12/07/06 and unable to select anything pass 01/22/06. Hope that makes sense.
In the BeforeUpdate event of the control put in some code that checks the control is between today and today +45.
- Private Sub CtrlName_BeforeUpdate(Cancel As Integer
-
If Me.CtrlName < Date() _
-
Or Me.CtrlName > Date() + 45 Then
-
Call MsgBox("Invalid Date")
-
Cancel = True
-
End If
-
End Sub)
Quote:
Originally Posted by JC21
Second part of my questions is I have another form which the source is from a table. In this table there is field which contains dates. The dates are appointments that are setup. On this form you are able to see the appointments from the past and those that are scheduled in the future. I would to restrict the form from showing appointments in the future. If the form is accessed today I would like for it to only show appointments for today and those in the past.
Any help or reference anyone can provide would be greatly appreciated.
Set record source of the form to
- SELECT * FROM [table] WHERE [yourdatefield] <= Date()