Thanks, so this is the full code that works in a stand alone form.
When I add this code to a main form as a sub-form I get no errors but it does not filter.
I looked at what you showed me but changing the reference to the controls does not seem to work. Any other suggestions.
Thanks
Option Compare Database
Public Sub cmdSearch_Click()
'FormName.Procedurename
Call Search
End Sub
Sub Search()
'Dim tempCriteriaForReport As TempVar
Dim strCriteria, strStatus, strYear, strMake, strModel As String
Dim varItem As Variant
'If Not IsNull (frm_Inventory!frm_Inventory_List!txtStatus)
'[frm_Inventory]![frm_Inventory_List]!
'''=========== code for status
'Forms![frm_Inventory]![frm_Inventory_List].Form![txtStatus]
'Me.[SubformName].Form.[ControlName]
'Forms!Orders![Orders Subform].Form.GetProductID
If Not IsNull(Me.txtStatus) Then
strStatus = "([Status] like ""*" & Me.txtStatus & "*"")"
strCriteria = strCriteria & " (" & strStatus & ")"
End If
'''=========== code for year
If Not IsNull(Me.txtYear) Then
strYear = "([Year] like ""*" & Me.txtYear & "*"")"
strCriteria = strCriteria & " And (" & strYear & ")"
End If
'''=========== code for make
If Not IsNull(Me.txtMake) Then
strMake = "([Make] like ""*" & Me.txtMake & "*"")"
strCriteria = strCriteria & " And (" & strMake & ")"
End If
'''=========== code for model
If Not IsNull(Me.txtModel) Then
strModel = "([Model] like ""*" & Me.txtModel & "*"")"
strCriteria = strCriteria & " And (" & strModel & ")"
End If
task = "select * from [qry_Inventory_List] where (" & strCriteria & ")"
Me.FilterOn = True
DoCmd.ApplyFilter task
'TempVars!tempCriteriaForReport = task '' set temp string criteria for report preview
'Me.txtTotal = FindRecordCount(task)
End Sub