filter table by dynamic column

TRIP82

New Member
Joined
Jun 11, 2016
Messages
28
Office Version
  1. 2013
Hi everyone,

I start this topic because after 2/3 days trying to find by myself a solution, i'm getting crazy :LOL: (i'm a completely newbie in ms access)

will post some pics to easy understanding what is my goal
this is my table:

svp57a.jpg


and in this form I want to filter table from multi column,....

dfburs.jpg


So first I have to choose which column I want to filter, once selected the combobox column distinct list should update automatically with unique values from the column I select.

I would be grateful if anyone can help me
Regards
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
If I understand, what you want is called cascading combo boxes (where "child" combos depend on the choices made in the "parent"). See
Dependent Combo Box in Access or search on 'cascading combo boxes'.
 
Upvote 0
Thanks for the reply but it's not that... I have two combobox's...

combobox 1 "select column to filter" I have all the column names from my table

combobox 2 "column distinct list" I should have a formula like this: Select distinct combobox1 from mytable name

is this possible?
 
Upvote 0
Yes, although that is a statement (select query statement) not a formula. If there is more than 1 choice in #2, your approach seems OK. If there is only one choice which is based on the first combo selection, having a second combo would not make sense - just pass the field name to a little function that runs your select statement. What follow is an example of what you could have if you used the AfterUpdate for the applicable combo to generate your statement. How useful this is is anybody's guess since you haven't provided a lot of info about what or how you're doing whatever it is.
Code:
Private Sub cmb1 AfterUpdate
RunSql (Me.cmb1)
'now do whatever it is that you intended to do with your sql statement
End Sub

Code:
Private Function RunSql(fld As String) As String
RunSql = "SELECT DISTINCT " & fld & FROM mytable;"
End Function
 
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,276
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top