The simplest way I know is to build a Function that can build your Filter string, and then call that function anytime one of your search criteria controls is updated. For example:
Function BuildSearch()
Dim sFilter As STring
If Nz(Me.cboDeviceType, "") <> "" Then
sFilter = "DeviceType=" & Me.cboDeviceType
End If
If Nz(Me.cboUserName, "") <> "" Then
If Len(sFilter) > 0 Then sFilter = sFilter & " AND "
sFilter = sFilter & " UserName='" & Me.cboUserName & "'"
End If
Me.YourSubformControl.Form.filter = sFilter
Me.YourSubformControl.Form.FilterOn = True
End Function
Now just call that function from your controls:
Sub cboDeviceType_AfterUpdate()
BuildSearch
End Sub
A few tips:
Filter strings are nothing more than valid SQL WHERE clauses without the word "WHERE", so you must follow the same rules:
Enclose text values in single or double quotes: "UserName='" & Me.cboUserName & "'" is surrounded by single quotes
Enclose Date values in Hash marks: "DateLoaned=#" & Me.txDateLoaned & "#"
Make SURE that you properly refer to your Subform Control. THis is the CONTROL on your main form that hosts the form you're using as a subform. It may or may not be named the same as the form you're using as a subform (i.e. the "Source Object"), so be careful when referring to that control.