Home Forums Programming General column selection on dynamic basis RE: column selection on dynamic basis

  • thanks you all for your prompt response. I'm so grateful for you all for spending your valuable time on assisting people like us.

    let me clear my requirement as follows. I'm not going to do a sophisticated thing as it appears. sorry if my original post give an incorrect impression about my requirement

    see, I have a access table with column headings like below(say table1)

    year , month , feeder name , FaultType1 , FaultType2 , FaultType3

    now I have created a form with combo boxes to select year month and FaultType etc... and i need to draw a pivot chart based on my selection in access form.

    it's easy to get the combo box values for year, month(for instance combo value for Year will be 2011,2012 etc..). code like below meet that requirement

    select Year from Table1 where Table1.Year=[Forms]![FormName]![Combo Name]etc..

    however I need user to select FaultType through another combo box(in the same form) and then draw a pivot chart based on the FaultType he selected. my combo box drop down values should be FaultType1, Faultype2,FaultType3 which is infact the column names in my Table1 and once he select a specific FaultType then a pivot chart should be drawn based on that selection.

    to do that I guess I have to write a SQL statement first to create another dynamic table based on user's selection and then draw the pivot chart

    my SQL query will be like below one;

    SELECT Year, Month, FeederName , "and the Fault type based on the user's selection through combo box" FROM Table1 WHERE etc...

    Here the FaultType is actually the column names in my Table1

    I need a help to fill the " " part in my above SQL which is on how to select the FaultType(1 or 2 or 3) from Table1 based on the users selection

    Thanks for helping 🙂