Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2004
    Posts
    58

    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):

    RecID,English,Maths,Science,Art,Music,etc
    1,Y,N,N,N,Y, etc
    2,N,Y,N,Y,N,etc
    3,N,Y,Y,Y,N,etc

    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.

  2. #2
    Join Date
    Apr 2004
    Location
    Derbyshire, UK
    Posts
    789
    Provided Answers: 1
    Hi

    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

    ie

    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
    Next I

    And assign this to the combo control

    cboSubjects.RowSourceType= “Value List”
    cboSubjects.RowSource = srtFieldlist
    cboSubjects.Requery


    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

    ie

    SQL=”SELECT Field list required in cobNames .. FROM table name(s) etc WHERE [“ & cboSubject & “] = Yes”

    And assign to next combo control

    cboNames.RowSourceType= “Table/Query”
    cboNames.RowSource = SQL
    cboNames.Requery


    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!


    MTB

  3. #3
    Join Date
    Sep 2004
    Location
    Dallas, TX
    Posts
    77
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •