The target form is frmServceEventsFind whose control source Record Source is qryServiceEvents.
In qryServiceEvents I put the following in the Criteria row for the SvcDate field:
Code: Select all
Between [Forms]![frmSvcEventParameters]![Date1] And [Forms]![frmSvcEventParameters]![Date2]
Forms!frmSvcEventParameters!Date1 as “Date with Time” (didn’t see a plain “Date” option)
Forms!frmSvcEventParameters!Date2 as “Date with Time”
That works if I open the query directly and manually enter the dates, but it isn't getting the dates from frmSvcEventParameters.
On frmSvcEventParameters I have the following vba on the cmdOk button click event:
Code: Select all
Private Sub cmdOk_Click()
Dim sStart As String
Dim dStart As Date
Dim sEnd As String
Dim dEnd As Date
If Not IsNull(Me.[cboMonth1]) And Not IsNull(Me.[cboYear1]) Then
sStart = Me.[cboMonth1] & " 1, " & Me.[cboYear1]
dStart = DateValue(sStart)
dEnd = DateAdd("m", 1, dStart)
dEnd = (DateSerial(Year(dEnd), Month(dEnd), 0))
End If
If dStart > Now() Then
MsgBox "Can't call a future month."
Exit Sub
End If
Me.[Date1] = dStart
Me.[Date2] = dEnd
DoCmd.OpenForm "frmServiceEventsFind", acViewNormal, acEdit
End Sub