Filter - a quick question

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
 
R

Rick Brandt

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
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top