OK, here is one way:
Create two more text boxes on the form "Main":
Name: DateMin1
Visible = No
Default = #1/1/1800#
Name: DateMax1
Visible = No
Default = #12/31/3000#
Add code:
Code:
Option Compare Database
Option Explicit
Private Sub Check40_Click()
If IsDate(Me.DateMin) And IsDate(Me.DateMax) Then
If Me.Check40 = True Then
Me.DateMin1 = Me.DateMin
Me.DateMax1 = Me.DateMax
Else
Me.DateMin1 = #1/1/1800#
Me.DateMax1 = #12/31/3000#
End If
End If
Me.Requery
End Sub
Private Sub Form_Load()
Me.Requery
End Sub
Change the criteria in the query to:
Between [forms]![main].[datemin1] And [forms]![main].[datemax1]
If the dates in Me.DateMin and Me.DateMax are valid dates, put them in Me.DateMin1 and Me.DateMax1. Otherwise use the default dates of #1/1/1800# and #12/31/3000#.
Both Me.DateMin and Me.DateMax must be valid dates..