Validation through calender control

Local time
Tomorrow, 02:53
Joined
Dec 2, 2011
Messages
26
Hi,

I've a little concern about Validation rule on date/time field on form:

I'm using Validation rule " Between #01-Apr-12# And #31-Mar-13# " on Challan_date field and it's working fine while entering manual entry but when someone uses calender control, it doesn't work at all. It accepts any date set through Calender control.

My concern is to restrict user to enter date between the criteria set.

Calender Control code:
---------------
Private Sub cmdCalendar_Click()
Set ctlIn = Me.Controls("Challan_date")
DoCmd.OpenForm "frmCalendar"
Me.Cln_Mode.SetFocus
End Sub

---------------

Please guide me to do so.
Thanks in advance.
 
Removed Validation rule
Code:
Between #01-Apr-12# And #31-Mar-13#

and used as

Code:
Private Sub Challan_date_BeforeUpdate(Cancel As Integer)
If (Me.Challan_date.Value < [StartDate]) Or (Me.Challan_date.Value > [EndDate]) Then
MsgBox ("Challan date is greater or less than your Fiscal year."), vbCritical, "Error"
Me.Challan_date = ""
Me.Challan_date.SetFocus
End If
End Sub
 

Users who are viewing this thread

Back
Top Bottom