Filter the form records with vba

al.81

New member
Local time
Today, 20:34
Joined
Sep 12, 2014
Messages
3
Hi,
would be thankful for help with the vba code for filtering the records of the form made out of a table. The form contains combos that contain the lists of unique records in several colomns of the source tale. So i need to filter the records of the form using the combination of the values of that combos. But can't even apply a single filter using this code:

Me.Filter = "Business = " & list59.Value
Me.FilterOn = True

"Business" is the name of the column in the source table, and the "list59" is the name of the combo which contains the unique records of the "Business"

the code takes place as a button "apply" is pressed
 
Try the below if it is a string.
Code:
Me.Filter = "Business = [B][COLOR=Red]'[/COLOR][/B]" & [B][COLOR=Red]Me.[/COLOR][/B]list59.Value [B][COLOR=Red]& "'"[/COLOR][/B]
Me.FilterOn = True
 
thanks for the reply, when i use the proposed code i get an input box which asks me to enter the value for the "Buseness", but the combo.value shows the correct text for it. I start to doubt that the whole thing is correct and suits the need, because even when i enter the correct definition for the "Business" filtering into that box, the thing still doesn't work, meaning the records are not filtered at all. I use MS Office 2010 which got all the recent updates. I also used this code:
forms.myform.form.filter...
forms.myform.form.filteron = true

... still doesn't work as intended
 
thanks for the reply, when i use the proposed code i get an input box which asks me to enter the value for the "Buseness", but the combo.value shows the correct text for it.
That happen if you refer to a control which is unknown, so check that the name of the control really is "List 59".

I also used this code:
forms.myform.form.filter...
forms.myform.form.filteron = true
Use:
Code:
Me.Filter = "Business = " ...
Me.FilterOn = True
Where do you have the code, in the "After update" for the control or ...?
If you can't get it then post a stripped version of your database with some sample data, zip it.
 
thanks, works as intended. it was a name for the column issue - which was single 'S'ed and the code contained double 'S' in the name.
 

Users who are viewing this thread

Back
Top Bottom