Lavenderchan
Technical User
Hello,
I am having problems with my code below. It will filter the form but its returning only a blank row. I do not think it is able to filter based on my query I am not sure why it is not able to select records from my query. What am I doing wrong?
Thanks,
Keri
I am having problems with my code below. It will filter the form but its returning only a blank row. I do not think it is able to filter based on my query I am not sure why it is not able to select records from my query. What am I doing wrong?
Code:
Private Sub Command1611_Click()
Dim varItem As Variant
Dim strSearch As String
Dim task As String
For Each varItem In Me!ListBuildingType.ItemsSelected
' use ASCII Chr(34) to replace Double Quotes in VB
'Chr(34) = "
' Use "Or" to get result from all states
strSearch = strSearch & "[Building_Type_ID] = " & Chr(34) & Me!ListBuildingType.ItemData(varItem) & Chr(34) & "Or"
Next varItem
If Len(strSearch) = 0 Then
task = "select * from [q_Comparsion Data Form] "
Else
strSearch = Left(strSearch, Len(strSearch) - 2) '' remove 2 charactors at the end, that is Or.
task = "select * from [q_Comparsion Data Form] where (" & strSearch & ")"
End If
DoCmd.ApplyFilter task
End Sub
Keri