var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Filter multiple colums from one Combo Box
I have a table that has multiple columns formated as check boxes. Example below (check box value indicated by Y or N):
What I want to do is to have a combo box on a form which lists the column headings (excluding RecID). When one of the headings is selected in this combo I want another combo box to be filtered to only display a list of names (linked by the RecID field) that have the check box enabled.
I would suggest this as one way
In the form load event
Open a DAO (or ADO ?) recordset with the fields you want in the combo control
Set db = CurrentDb()
Set rs = db.OpenRecordset("SELECT English, Maths, Science, Art, Music, etc FROM rblName”)
Create a field list
StrFieldList = rs.Fields(0).Name
For i = 1 To rs.Fields.Count – 1
StrFieldList= StrFieldList & “;” & rs.Fields(i).Name
And assign this to the combo control
cboSubjects.RowSourceType= “Value List”
cboSubjects.RowSource = srtFieldlist
You could of course just type the fields you require into the combo control in design view !?
In the change event of cboSubject use this code to construct a SQL string to assign to the next combo control cboNames
SQL=”SELECT Field list required in cobNames .. FROM table name(s) etc WHERE [“ & cboSubject & “] = Yes”
And assign to next combo control
cboNames.RowSource = SQL
This will dynamically change the filtered field when it is selected (with any luck because I have not actually tried it!?).
I’m sure someone will point out the error of my ways if it won’t work!
can make it simple:
for the filter combo box, you can just set the property:
RowSourceType = "Value List" and RowSource =fiel1;2;3;....
in the code:
filter combo box click , write code:
strsql = "select [" & cbfilter.Value & "] from dbo_tbl_irrfunds"
cbdata.RowSourceType = "Table/Query"
cbdata.RowSource = strsql