Hi,
I’m totally new to MS Access. I have what seems to be a pretty simple thing to accomplish – I need to apply a filter via a VBA call to a datagrid on a subform. I have a form, a list box and a subform with a datagrid on it. When a user selects one or more choices in the list box, I need to click on a Filter command button and filter out the datagrid.
I was using the following code -
Private Function AppluFilter()
Dim strValue As String
Dim oItem As Variant
Dim i As Integer
For Each oItem In lstFilter.ItemsSelected
If i = 0 Then
strValue = CStr(lstFilter.ItemData(oItem))
Else
strValue = strValue & ", " & CStr(lstFilter.ItemData(oItem))
End If
i = i + 1
Next
Me.sbfDetails.Form.Filter = "VenNum In ( " & strValue & ")"
Me.sbfDetails.Form.Filter = True
End Function
VenNum is the unique identifier and its numeric. The function does not generate an error, however it does not apply the filter either. What am I missing?
Thank you