Thanks to anyone who can help!
Here is my problem. I have a continous form with a list of item. Now I want to filter those items based on the selections of the 3 combo boxes in the header of the form. I have the combo boxes there and tried to borrowed some code and modify it. But it is not working.
When I try to execute the code with the command button. I get this error.
Run-tim error '3075'
Missing),], or Item in query
expression '([mfgName]= "136"
The 136 in this error is the ID field of the table with my values in it. This field is not part fo the combo box, it should only be reading the name field. I tried changing mfgName to mfgID, but I still get the same error.
I am also not sure about the string length defined below as some of my string lengths are much longer than 5 characters, so not sure I want to cut them off. I want to match them exactly, so I would think this part of the code could be eliminated.
Here is the code attached to the command button:
'Text field example. Use quotes around the value in the string.
If Not IsNull(Me.cmbFilterEquip) Then
strWhere = strWhere & "([EquipName] = """ & Me.cmbFilterEquip & """) AND"
End If
'Another text field example. Use Like to find anywhere in the field.
If Not IsNull(Me.cmbFilterMfg) Then
strWhere = strWhere & "([MfgName] = """ & Me.cmbFilterMfg & """) AND"
End If
'Another text field example. Use Like to find anywhere in the field.
If Not IsNull(Me.cmbFilterCat) Then
strWhere = strWhere & "([CatName] = """ & Me.cmbFilterCat & """) AND"
End If
'************************************************* **********************
'Chop off the trailing " AND ", and use the string as the form's Filter.
'************************************************* **********************
'See if the string has more than 5 characters (a trailng " AND ") to remove.
lngLen = Len(strWhere) - 5
If lngLen <= 0 Then 'Nah: there was nothing in the string.
MsgBox "No criteria", vbInformation, "Nothing to do."
Else 'Yep: there is something there, so remove the " AND " at the end.
strWhere = Left$(strWhere, lngLen)
'For debugging, remove the leading quote on the next line. Prints to Immediate Window (Ctrl+G).
'Debug.Print strWhere
'Finally, apply the string as the form's Filter.
Me.Filter = strWhere
Me.FilterOn = True
End If