Here is the coding for my filter, it filters various attributes of a person:
temp = "" 'reset value of global string variable
If Not IsNull(cmbGender.Value) And (cmbGender.Value) <> "Any" Then
If temp = "" Then
temp = "Gender=""" + cmbGender.Value + """"
Else
temp = temp + "and Gender=""" + cmbGender.Value + """"
End If
End If
If Not IsNull(cmbHairColor.Value) And (cmbHairColor.Value) <> "Any" Then
If temp = "" Then
temp = "HairColor=""" + cmbHairColor.Value + """"
Else
temp = temp + "and HairColor=""" + cmbHairColor.Value + """"
End If
End If
If Not IsNull(cmbHairType.Value) And (cmbHairType.Value) <> "Any" Then
If temp = "" Then
temp = "HairType=""" + cmbHairType.Value + """"
Else
temp = temp + "and HairType=""" + cmbHairType.Value + """"
End If
End If
If Not IsNull(cmbEyeColor.Value) And (cmbEyeColor.Value) <> "Any" Then
If temp = "" Then
temp = "EyeColor=""" + cmbEyeColor.Value + """"
Else
temp = temp + "and EyeColor=""" + cmbEyeColor.Value + """"
End If
End If
If Not IsNull(cmbEthnicity.Value) And (cmbEthnicity.Value) <> "Any" Then
If temp = "" Then
temp = "Ethnicity=""" + cmbEthnicity.Value + """"
Else
temp = temp + "and Ethnicity=""" + cmbEthnicity.Value + """"
End If
End If
DoCmd.Close
DoCmd.OpenForm "frmSearchMain", acNormal, , temp 'open search form
All the filter button on my "frmSearchMain" form does is open the filter form again.