Access 2003 - Combo box does not filter form after using toolbar (or right-click) remove filter.

Have a continuous form that has a combo box to filter for records by name.  It works until you use remove filter using the toolbar or right click method.  
mlaurinAsked:
Who is Participating?
 
lee555J5Commented:
Is Analyst1 the name of the combobox?

If it is, replace the whole Sub with the attached code.

Build your filter statement based on the BoundColumn of the combobox.
Examples:

If the combobox has only 1 column (LastName) and the form has a LastName field,
filter_expression: "LastName = " & Chr(39) & Analyst1 & Chr(39)

If the combobox has 2 columns (EmployeeID and EmployeeName) and the bound column is the first,
filter_expression: "EmployeeID = " & Analyst1

The Chr(39) is the single quote and it is usually clearer to use this instead of stacking lots of single and double quotes together. Use single quotes to equate strings.

Lee

Private Sub Analyst1_AfterUpdate()

  Me.Filter = Put your filter_expression here
  Me.FilterOn = True

End Sub

Open in new window

0
 
peter57rCommented:
Please post the code for the combo box (combobox afterupdate event procedure I would expect)
0
 
mlaurinAuthor Commented:
Here it is:

Private Sub Analyst1_AfterUpdate()
Me.Requery
End Sub
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
mlaurinAuthor Commented:
That worked!  I originally put the filter in the query field which works great except if used in combination with the toolbar filter.  So thanks for the solution that does work.
0
 
mlaurinAuthor Commented:
I've requested that this question be closed as follows:

Accepted answer: 0 points for mlaurin's comment http:/Q_27424025.html#37058889
Assisted answer: 500 points for lee555J5's comment http:/Q_27424025.html#37058623

for the following reason:

Thanks!!
0
 
mlaurinAuthor Commented:
Made a mistake with accepting.  Not sure how it happened that my comment shows as accepted.  It should only be ee555J5's.  
Will try to figure out how to change this!
0
 
mlaurinAuthor Commented:
Made a mistake with accepting.  Not sure how it happened that my comment shows as accepted.  It should only be ee555J5's.  
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.