Filter in Access form

keshavmodi

Registered User.
Local time
Today, 16:50
Joined
Oct 6, 2010
Messages
14
I have a combo box names "combo_1" in access bound Form. The combo box is bound to the field "Field_1" in the table "Table_1". Whenever I select a value from the combo box, I want the record set to be filtered by that value.

I have tried the following code

Private Sub Combo_1_AfterUpdate()

Me.filter=" [Table_1.Field_1]= ' " & combo_1 & " ' "
me.FilterOn = True

End Sub


However this is not working. Please let me know the solution.

Thank you
 
There are spaces in your criteria, plus [Table_1.Field1] is not the same as [Table_1].[Field1]. If the record source is using one table then you can omit the table name. Use this:

Me.filter = "[Field_1] = '" & combo_1 & "'"

OR

Me.filter = "[Field_1] = " & Chr(34) & combo_1 & Chr(34)
 
The combo box is bound to the field "Field_1" in the table "Table_1".

A search combobox should be UNBOUND!! If you change the combobox then you also change the current record if it is bound to your recordsource.


JR
 
Thank You vbaInet. Your reply was really useful.

@ JANR: Thank you for the reply. In the before update event of the form i am "undoing" everything. This prevents any changes to be made. Hope this will prove to be enough.
 

Users who are viewing this thread

Back
Top Bottom