I have an Inventory form that displays inventory in a datasheet type view, which has filtering textboxes at the top. The first filter criteria field (Cat) uses a combo box to select which category to filter the inventory by (Prototype;Production). Here is the filter code...
Private Sub UpdateFilter()
Dim Cat As String
Dim fltCat As String
Me.Filter = ""
Me.FilterOn = False
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If IsNull([cbxSCat]) = False And [cbxSCat] <> "" Then
Cat = [cbxSCat]
fltCat = "Cat like '" & Cat & "*' "
If Me.Filter = "" Then
Me.Filter = fltCat
Else
Me.Filter = Me.Filter & "and " & fltCat
End If
End If
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If Me.Filter = "" Then
ClearFilter
Else
Me.FilterOn = True
End If
End Sub
This form works great.
On my Main User Menu form, I have a command button to check out Prototype parts, and another to check out Production parts. Here is what I have in the OnClick property of the menu's Prototype button...
Private Sub cmdProtoCO_Click()
Dim strDocName As String
strDocName = "frmInventory"
DoCmd.OpenForm strDocName
Forms!frmInventory.FilterOn = False
Forms!frmInventory!cbxSCat = "Prototype"
Forms!frmInventory.FilterOn = True
End Sub
When I click this button, it opens the Inventory form, and "Prototype" is displayed in the combobox, but the form isn't filtered. How can I activate the filter in the code so the Inventory form is showing only the Prototype parts when it opens?
Thanks for any & all help.