Hi folks
I have an unbound form "frmStockInvHistory"
On this form I have 3 tabs, each with a different form displaying different information. These are "FrmStockOutHistory", "FrmInvAddedHistory", and "FrmInvUsedHistory".
I am trying to apply a filter to a field "StockItem" on each form but at this stage have only been testing this on "FrmStockOutHistory". (Once I got this correct I was going to move on to the other two forms.
My code is:
Private Sub txtNameFilter_KeyUp(KeyCode As Integer, Shift As Integer)
Dim filterText As String
'Apply or update filter based on user input.
If Len(TxtNameFilter.Text) > 0 Then
filterText = TxtNameFilter.Text
Me.Form.Filter = "[FrmStockInvhistory]![FrmStockOutHistory]![StockItem] LIKE '*" & filterText & "*'"
Me.FilterOn = True
'Retain filter text in search box after refresh.
TxtNameFilter.Text = filterText
TxtNameFilter.SelStart = Len(TxtNameFilter.Text)
Else
' Remove filter.
Me.Filter = ""
Me.FilterOn = False
TxtNameFilter.SetFocus
End If
End Sub
I have tested this on a standard form without the tabs and it works fine but I cannot get it to work on the form with tabs.
Would appreciate any assistance with this.
Many thanks
I have an unbound form "frmStockInvHistory"
On this form I have 3 tabs, each with a different form displaying different information. These are "FrmStockOutHistory", "FrmInvAddedHistory", and "FrmInvUsedHistory".
I am trying to apply a filter to a field "StockItem" on each form but at this stage have only been testing this on "FrmStockOutHistory". (Once I got this correct I was going to move on to the other two forms.
My code is:
Private Sub txtNameFilter_KeyUp(KeyCode As Integer, Shift As Integer)
Dim filterText As String
'Apply or update filter based on user input.
If Len(TxtNameFilter.Text) > 0 Then
filterText = TxtNameFilter.Text
Me.Form.Filter = "[FrmStockInvhistory]![FrmStockOutHistory]![StockItem] LIKE '*" & filterText & "*'"
Me.FilterOn = True
'Retain filter text in search box after refresh.
TxtNameFilter.Text = filterText
TxtNameFilter.SelStart = Len(TxtNameFilter.Text)
Else
' Remove filter.
Me.Filter = ""
Me.FilterOn = False
TxtNameFilter.SetFocus
End If
End Sub
I have tested this on a standard form without the tabs and it works fine but I cannot get it to work on the form with tabs.
Would appreciate any assistance with this.
Many thanks