I changed text box to combo box. the name of combox is combo76 .while selecting the list from combo box and toDate and fromDate then clicking on search command it doesn't give the desired result.
So please modify the code based on combo box, name combo76.
Any modification below code based on combo box.
Private Sub Search_Click()
'i want to click search command button after input from date and to date field value then it return all corresponding records.
Dim strCriteria As String, task As String
Me.Refresh
If IsNull(Me.FromDate) Or IsNull(Me.ToDate) Then
MsgBox " Enter the Date Range", vbInformation, "Date Range required "
Me.FromDate.SetFocus
Exit Sub
End If
'if costCode is required in the search, uncomment the next 5 lines
'' If IsNull(Me.costCode) Then
'' MsgBox "costCode is required", vbInformation, "costCode required"
'' Me.costCode.SetFocus
'' Exit Sub
'' End If
If Not IsNull(Me.costCode) Then
strCriteria = "CCode ='" & Me.costCode & "' AND "
End If
strCriteria = strCriteria & "[dDate]>= #" & Me.FromDate & "# And [dDate] <= #" & Me.ToDate & "#"
task = " select * from woPR where " & strCriteria & " order By [dDate]"
'Debug.Print task
Me.RecordSource = task
If Me.RecordsetClone.RecordCount = 0 Then
MsgBox "no match"
Me.RecordSource = "select * from woPR"
End If
End Sub