Filter - a quick question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

The code below removes the previous filter and finds the record in the main
form with DWG No. matches that selected in combo box cboDWGNo. But now
instead of just finding the record, I'd like the combo box to "filter" the
record. Any idea? Thanks

Extra info:
1) The main form is based on a query called qryDrawings.
2) The RowSource of cboDWGNo is also from the same query:
SELECT [qryDrawings].[DWGNo] FROM [qryDrawings]

Private Sub cboDWGNo_AfterUpdate()
' Remove previous filter.
Me.FilterOn = False
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[DWGNo] = '" & Me![cboDWGNo] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub
 
Sam Kuo said:
The code below removes the previous filter and finds the record in the main
form with DWG No. matches that selected in combo box cboDWGNo. But now
instead of just finding the record, I'd like the combo box to "filter" the
record. Any idea? Thanks

Extra info:
1) The main form is based on a query called qryDrawings.
2) The RowSource of cboDWGNo is also from the same query:
SELECT [qryDrawings].[DWGNo] FROM [qryDrawings]

Private Sub cboDWGNo_AfterUpdate()
' Remove previous filter.
Me.FilterOn = False
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[DWGNo] = '" & Me![cboDWGNo] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

Private Sub cboDWGNo_AfterUpdate()
' Apply new filter
Me.Filter = "[DWGNo] = '" & Me![cboDWGNo] & "'"
Me.FilterOn = True
End Sub
 
Super! Thanks Rick :)

Rick Brandt said:
Sam Kuo said:
The code below removes the previous filter and finds the record in the main
form with DWG No. matches that selected in combo box cboDWGNo. But now
instead of just finding the record, I'd like the combo box to "filter" the
record. Any idea? Thanks

Extra info:
1) The main form is based on a query called qryDrawings.
2) The RowSource of cboDWGNo is also from the same query:
SELECT [qryDrawings].[DWGNo] FROM [qryDrawings]

Private Sub cboDWGNo_AfterUpdate()
' Remove previous filter.
Me.FilterOn = False
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[DWGNo] = '" & Me![cboDWGNo] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

Private Sub cboDWGNo_AfterUpdate()
' Apply new filter
Me.Filter = "[DWGNo] = '" & Me![cboDWGNo] & "'"
Me.FilterOn = True
End Sub
 
Back
Top